What is hybrid search?
Hybrid search runs keyword and vector search together and merges the two ranked lists. How the merge works, when it helps a RAG system and how to test it.
Hybrid search runs a keyword search and a vector search over the same content and merges the two result lists into one ranking. It is the usual retrieval step in a RAG pipeline when queries mix exact terms with questions in natural language.
Each method fails differently. Elastic says lexical search can miss content that is worded differently, and semantic search can add noise when the context is ambiguous. Hybrid search offsets both.
Why keyword search stays in the mix
Embeddings capture meaning, not spelling. Anthropic writes that embedding models “can miss crucial exact matches”, and gives the query “Error code TS-999” as an example where an embedding search may return general error-code content instead of the exact match. BM25, the standard keyword ranking function, looks for the exact string, which makes it useful for unique identifiers and technical terms.
The reverse also holds. The BEIR benchmark, 18 public datasets built to test retrieval models on data they were not trained on, found BM25 a robust baseline, while dense retrieval models are cheaper to run but often underperform other approaches. Neither side wins everywhere, which is the case for running both.
How the two lists are merged
The two retrievers score documents on different scales, so the merge step is the real design choice. There are two families.
| Method | How it works | Trade-off |
|---|---|---|
| Reciprocal rank fusion (RRF) | Scores each document from its rank in each list, ignoring raw scores. | Elastic recommends it as the starting point because it needs little tuning. It throws away how far apart scores were. |
| Normalize, then weight | Rescales each retriever’s scores to a common range (for example min-max), then combines them with weights. | Elastic notes it gives finer control but needs experimentation and is sensitive to the dataset. |
Documentation from search engines shows how the two look in practice:
- Elastic’s RRF docs set
rank_constantto 60 by default, where a higher value gives lower-ranked documents more influence.rank_window_sizesets how many top results each retriever contributes before fusion. - OpenSearch offers both in a search pipeline. Its normalization processor converts each clause’s scores to a common scale and keeps the margins between documents, so it fits when score gaps matter. Its score ranker uses RRF and suits a setup where you have not yet measured how the clauses score. The docs example combines
min_maxnormalization with anarithmetic_meanand weights of 0.3 and 0.7. - Cloudflare’s AI Search defaults to
rrf, which it recommends for most use cases, and offersmax, which keeps the higher normalized score. Reranking there is optional and off by default.
What the gain looks like
Anthropic’s September 2024 tests on a mix of codebases, fiction and papers are one of the few public numbers for adding BM25. With a baseline top-20 retrieval failure rate of 5.7%, contextual embeddings alone reached 3.7%, adding contextual BM25 reached 2.9%, and adding a reranker on the top 150 chunks reached 1.9%. These are Anthropic’s datasets, not yours, and the BM25 step there is applied to chunks that had context prepended (see chunking strategies).
How to test it on your own data
Hybrid search adds a second index and a merge step, so it should earn its place on your queries.
- Collect real queries, including ones with product names, identifiers and error strings, and mark which documents should come back (a golden dataset is the usual form).
- Score keyword only, vector only and hybrid on the same set with retrieval metrics such as context precision and recall.
- Vary one thing at a time: the merge method, the weights or rank constant, and the number of results each retriever contributes.
- Check the final answers too, with the checks in RAG evaluation, since better retrieval does not always give a better answer.
The embedding side matters as well, and its scores follow the rules in semantic similarity.
Tracing retrieval
When a hybrid query returns the wrong chunk, you need to see what each retriever returned and how the merge ordered them. HoneyHive’s LlamaIndex integration traces query engines, retrieval and embeddings, so those steps show up as spans. For how traces are structured, see LLM tracing.
FAQ
What is hybrid search?
Search that runs two methods, usually keyword (lexical) and vector (semantic), and merges them into one ranked list. Elastic describes it as blending two or more search methods into a single ranked list.
What is reciprocal rank fusion?
A way to merge result lists using each document's rank instead of its score. Elastic's docs say it needs no tuning and the retrievers' scores do not have to be related, and give 60 as the default rank constant.
Is hybrid search better than vector search?
Often, for queries with exact terms such as identifiers or error codes. Anthropic's tests cut the top-20 retrieval failure rate from 3.7% to 2.9% by adding BM25 to contextual embeddings. That is one team's data, so measure on your own queries.
Do you need to normalize scores in hybrid search?
Only if you combine scores directly. Elastic says linear combination needs scores normalized to a comparable range, while reciprocal rank fusion uses ranks and skips that step.