data-infra
Glossary ↗Hybrid Search
Hybrid search combines two fundamentally different retrieval methods — dense vector (semantic/embedding-based) search and sparse keyword search (typically BM25, a statistical ranking function that scores documents by term frequency) — into a single query, blending their results to get the strengths of both. Why it matters for AI/SaaS builders: pure semantic search, for all its strength at understanding paraphrased meaning ("cancel my subscription" matching a document about "terminating your plan"), is genuinely bad at exact-match precision — it can fail to prioritize a document containing the literal product SKU, error code, or acronym a user typed, because embedding models compress specific tokens into a general semantic representation that doesn't strongly preserve exact-string identity. Pure keyword search has the opposite problem: it's excellent at exact matches but blind to synonyms, paraphrasing, and conceptual similarity. Hybrid search exists because production retrieval quality — measured against real user queries, not curated demo queries — is consistently better with both signals combined than with either alone, and this has become close to a best-practice default for serious RAG systems as of 2025–2026. How it works: the two most common combination strategies are (1) score fusion, most commonly Reciprocal Rank Fusion (RRF), which runs both a vector search and a keyword search independently, then merges the two ranked result lists into one final ranking using a formula that rewards items appearing near the top of either list, without needing to normalize incomparable raw scores (cosine similarity and BM25 scores live on entirely different scales, which is why naive score-averaging performs poorly); and (2) a single weighted query where the vector database computes both a dense and sparse score for each candidate and combines them with a tunable alpha weight (`alpha=1` pure vector, `alpha=0` pure keyword). Pinecone, Weaviate, Elasticsearch (with its `dense_vector` field type), and OpenSearch all support hybrid search natively as of recent versions. Worked example: a technical-documentation SaaS's AI search handles the query "error TS2345." Pure semantic search might rank generic "TypeScript type error" articles highly without prioritizing the one article that literally mentions error code TS2345, because the embedding compresses the specific code into a general "type mismatch" concept. Hybrid search's keyword component finds the exact-match article containing "TS2345" via BM25 and, through RRF fusion with the semantic ranking, surfaces it at position 1 — combining "understands what you mean" with "finds the exact thing you typed." The team validates the improvement with a small labeled eval set of real support queries before shipping, since hybrid search's alpha-weighting is easy to over-tune toward whichever handful of example queries a developer happened to test manually.
Related terms