While updating Semantic Docs and a private fork I call Astro Vault, I wanted to understand how hybrid search fits together. The two projects are closely related, and my vault doesn’t have a huge amount of content. I could spend a lot of time optimizing search, but my priority is a useful starting point that works reliably.
The tuning of hybrid search is interesting to me insofar as I want to understand the rabbit holes that I might go down if I were so inclined. However, the main thing I care about for these projects is making sure someone can still search if the embedding layer goes down.
So; what happens when the application can’t create an embedding for the search request?
Combining results and handling failures
In these projects, hybrid search combines keyword and vector retrieval. Keyword search uses the words in the query. Vector search uses an embedding of the query to look for related content. That can help when someone describes a problem without knowing the terminology used in the documentation.
The keyword path doesn’t need a query embedding. In principle, it can keep answering requests while the embedding provider is unavailable. The application still has to make that happen.
The current code in these two related projects handles that case differently.
In Astro Vault, with hybrid search enabled, keyword retrieval starts alongside the embedding request. If the embedding provider fails or reaches its five-second deadline, a successful keyword query can supply the response. The search loses its semantic contribution, but the user can still get results.
Semantic Docs also starts both paths concurrently. For an uncached request, however, its search endpoint awaits them with Promise.all. If embedding or vector retrieval rejects, the endpoint returns an error even if keyword retrieval succeeded. It already tolerates keyword failures in the other direction, allowing vector results through.
Those are findings from the local code and existing tests, not a live outage experiment. They show why “hybrid” alone doesn’t tell me what happens when a dependency fails.
There’s still work to do around timeout handling and consistent fallback behavior. I’d want those behaviors tested before treating the search as a dependable starting point.
What I’d want from a starting point
I’d want keyword search to be independently usable, with an explicit deadline around the embedding request. If the semantic path is unavailable, the application should be able to return the keyword results it has and record why it fell back.
A successful search with no matches also needs to remain distinguishable from a failed search. An empty keyword result can be a valid answer. A database error shouldn’t quietly become “nothing found.”
I’d check those behaviors before spending much time adjusting ranking weights: a normal hybrid request, an unavailable embedding provider, a slow provider, and a query that correctly returns no results. Those checks answer whether the service remains usable under the conditions it claims to handle.
Neither project’s response currently includes an explicit degraded-mode field. That leaves another design choice: how much of the fallback should be visible to the user, and what should be available to the person operating the service? Server logs can help explain a partial result without requiring the reader to understand the search architecture.
Where the weights fit
Once both searches return results, fusion combines their ranked lists. Reciprocal rank fusion, or RRF, uses each document’s position instead of treating keyword and vector scores as directly comparable.
A weighted version gives each list a configurable contribution. Favoring keyword results might suit one collection of documents; another collection might benefit from more semantic influence. The weights don’t decide what happens when an embedding request fails. That belongs to the request-handling code.
There are plenty of other things to explore: how many candidates each search retrieves, how documents are divided into chunks, which embedding model is used, and whether the query is a complete question or only a few characters typed so far. I’d want evidence of a specific problem before changing several of those at once.
Astro Vault already has a small relevance evaluation with 40 queries: ten identifiers and thirty natural-language questions. It runs real keyword retrieval alongside recorded vector results. That gives it a repeatable way to compare ranking changes without making live embedding calls.
It also limits what the evaluation tells us. Recorded vectors don’t test whether today’s provider is reachable, and full questions don’t establish how well search-as-you-type works. A small query set is a useful regression check; repeatedly tuning against it doesn’t establish the best settings for everyone who might use the project.
For an open-source starting point, I’d rather make the defaults understandable, the failure behavior explicit, and the evaluation easy to extend. Someone with more content or different queries can then investigate the tuning that matters to them.
I want to know where the optimization work could lead. First, I want someone to type a query and get a useful answer, including when one part of the search isn’t available.
Sources
- Semantic Docs search endpoint: the inspected request-handling implementation.
- SQLite FTS5: keyword matching and BM25 ranking.
- Reciprocal Rank Fusion: the original rank-fusion paper.
- Hybrid search overview: combining text and vector retrieval.
I’d appreciate a follow. You can subscribe with your email below. The emails go out once a week, or you can find me on Mastodon at @[email protected].