Hybrid search queries a BM25 keyword index and a vector similarity index together, then merges the two ranked lists so exact-term matches and paraphrased meaning both reach the result set.
Two indexes, one query: BM25 and vector similarity
The system sends the user's query to both indexes at the same time. BM25 retrieves documents that contain the exact terms, which suits rare tokens such as error codes, product SKUs and acronyms. The vector index captures meaning, so it can match “how do I cancel” with “terminate my subscription” even though no words overlap.
- Submit the query to both indexes.
- Retrieve exact-match results from BM25.
- Retrieve semantic matches from the vector index.
- Merge the lists with Reciprocal Rank Fusion.
- Return the final ranked results.
Merging the lists with Reciprocal Rank Fusion
The two result lists are merged with Reciprocal Rank Fusion or a weighted scoring system. Either method combines the signals from both indexes. A document that ranks high in BM25 but low in the vector list can still rise on the strength of its exact match.
Think of it as a UNION over two databases. The analogy has a limit: the indexes measure different things. Keyword search scores surface matches and vector search scores semantic closeness, so the merge has to combine two relevance signals and deduplicating rows is not enough.
In a technical support setting, a user who types a specific error code gets it from BM25. A user who describes the problem in plain language gets matches from the vector index. The fused list serves both.
Where pure vector and pure BM25 each fail
Pure vector search can look modern and sufficient, but embeddings can confuse near-identical identifiers. ‘ERR_2043’ and ‘ERR_2049’ may land close together, so the right document goes missing. Pure BM25 overlooks synonyms and rephrasing that users commonly use.
The hybrid approach costs an extra query and a merge step. It usually beats either method alone, especially where queries mix technical jargon with natural language.
Choosing BM25, vector or hybrid
| Situation | Choice | Reason |
|---|---|---|
| Many specific codes, names or technical terms | Lean on BM25 | Exact tokens decide relevance. |
| Conversational Q&A or user-generated content | Lean on vector | Phrasing varies and meaning matters. |
| Unpredictable queries, as in most production systems | Hybrid | It is the safe default and covers both. |
Example scenario: relevance falls 30% in a week
One possible cause is an imbalance in the weights. If the BM25 component dominates, exact matches outrank semantically relevant results and users get a worse experience.
- Check the weights assigned to keyword and vector scores.
- Log the top N results for sample queries and compare relevance scores from both models.
- A/B test other weight settings.