Hybrid search in vector databases blends keyword-based (BM25) and semantic (vector embedding) search to give you the best of both worlds, but the real magic is in how they fuse their results.
Let’s see it in action. Imagine a collection of product descriptions.
[
{
"id": "prod_001",
"name": "Cozy Wool Blanket",
"description": "A warm, knitted blanket perfect for chilly evenings. Made from 100% merino wool."
},
{
"id": "prod_002",
"name": "Lightweight Down Jacket",
"description": "Stay warm without the bulk. This jacket uses premium down fill for superior insulation."
},
{
"id": "prod_003",
"name": "Organic Cotton Throw",
"description": "Soft and breathable, this throw is ideal for year-round comfort. Certified organic cotton."
}
]
We’d embed the description field into vectors and also index it for BM25. If you search for "warm blanket", here’s what happens:
- BM25 finds
prod_001andprod_003strongly because they contain the exact keywords "warm" and "blanket". - Semantic Search finds
prod_001(because "warm," "blanket," and "chilly evenings" are semantically similar to "warm blanket") and potentiallyprod_002(because "warm" and "insulation" are related).
The fusion step is where the system combines these scores. It doesn’t just pick the top results from each; it mathematically merges their relevance scores, often using a weighted average or a more complex algorithm, to rank the combined list. A result that’s good at both keyword and semantic matching will bubble to the top.
This whole process solves the "keyword precision vs. semantic recall" dilemma. BM25 is great for exact matches and specific terminology (like product SKUs or technical specs), while semantic search excels at understanding nuance, synonyms, and the intent behind a query. Hybrid search ensures you don’t miss relevant items because they used slightly different wording or because your query was too abstract for pure keyword matching.
Internally, the database maintains two separate indexes: an inverted index for BM25 and an Approximate Nearest Neighbor (ANN) index for vector embeddings. When a hybrid query comes in, both indexes are consulted. The query is transformed into both a set of keywords for BM25 and a vector for semantic search. The results from each search are then assigned scores, and a fusion algorithm combines these scores into a final, unified ranking. The key levers you control are the weighting of BM25 versus semantic scores in the fusion algorithm and the choice of ANN algorithm for efficient vector search.
A common misconception is that hybrid search simply concatenates the top N results from each search type. In reality, effective fusion requires a more sophisticated approach to re-ranking, often involving a learning-to-rank model or a carefully tuned weighted sum that accounts for the different scoring scales of BM25 and vector similarity metrics. Without this, you might end up with a list that’s either too keyword-heavy or too semantically driven, failing to leverage the strengths of both.
The next step is understanding how to tune the fusion weights for optimal performance on your specific dataset and query patterns.