Dev tools
Hybrid Search Explained: BM25, Vectors and RRF
Hybrid search blends keyword and vector results into one ranking. Learn how BM25, semantic search and reciprocal rank fusion work, and how to tune them.
Hybrid search runs two kinds of search over the same data, a keyword search and a vector search, and merges their results into a single ranked list. Keyword search is good at exact words, names and codes. Vector search is good at meaning, even when the words differ. Put together, they catch what each one misses on its own, which is why hybrid search has become the default retrieval setup for many RAG systems and site search engines.
This guide explains how each half works, how the results are merged, how to tune the balance, and when hybrid search is worth the extra work. If you want the hands-on Postgres version, our pgvector tutorial shows the SQL. Here we focus on the ideas that apply to any search engine.
Why Hybrid Search Exists
Imagine a help centre with thousands of articles. Two users search it:
- One types "error E-4012". The answer is an article that contains that exact code.
- Another types "my payment keeps getting declined". The best article is titled "Card transactions failing at checkout" and never uses the word "declined."
Classic keyword search nails the first query and fails the second, because it only matches words. Vector search does the opposite: it understands that "declined" and "failing" mean similar things, but it can blur exact codes like "E-4012" into nearby, wrong ones.
Real users send both kinds of queries, often mixed together. Hybrid search handles both without making you guess which kind of query is coming.
How Keyword Search Works: BM25
Most keyword search engines rank results with BM25, a scoring formula that has been the standard for decades. It is the default ranking in Elasticsearch, OpenSearch and Apache Lucene, which they are built on.
BM25 scores a document higher when:
- The query words appear in it, and appear more than once. But the gain flattens out: the tenth mention of a word adds much less than the second. The parameter
k1controls how quickly it flattens (Lucene's default is 1.2). - The words are rare across the collection. Matching "E-4012" counts for much more than matching "the" or "error," because rare words carry more information. This is the inverse document frequency (IDF) part.
- The document is short. A match in a short paragraph is a stronger signal than the same match in a 50-page manual. The parameter
bcontrols this length penalty (default 0.75).
BM25 is fast, needs no machine learning model, works in every language that can be split into words, and is easy to debug: you can see exactly which words matched. Its weakness is that it has no idea what words mean. "Car" and "automobile" are as unrelated to it as "car" and "banana."
How Vector Search Works: Semantic Search
Vector search, often called semantic search, turns text into lists of numbers called embeddings. An embedding model places texts with similar meaning close together in a high-dimensional space. At query time, the query is embedded too, and the engine returns the documents whose vectors are nearest to it, usually measured with cosine similarity.
This is what lets "payment keeps getting declined" find "card transactions failing." The embedding model learned from huge amounts of text that those phrases mean nearly the same thing.
Semantic search has its own blind spots:
- Exact identifiers: product SKUs, error codes, version numbers and names are often split into odd pieces and lose their exactness.
- Rare or new words: terms the embedding model never saw in training, such as your internal project names, end up with vague vectors.
- Negation and small details: "laptops without a touchscreen" can land close to "laptops with a touchscreen."
- No clear "why": it is hard to explain why a result was returned.
How Hybrid Search Merges Results
The tricky part is combining two lists whose scores mean completely different things. A BM25 score might be 14.2, and a cosine similarity might be 0.83. You can't simply add them. There are two common approaches.
Reciprocal rank fusion (RRF)
Reciprocal rank fusion ignores the raw scores and uses only each document's position in each list. Each document gets:
score = 1 / (k + rank in keyword list) + 1 / (k + rank in vector list)
A document missing from one list simply gets nothing from that list. The constant k is usually 60, the value used in the original 2009 research paper by Cormack, Clarke and Büttcher, and the default in Elasticsearch.
A quick example with k = 60:
| Document | Keyword rank | Vector rank | RRF score |
|---|---|---|---|
| A | 1 | 3 | 1/61 + 1/63 = 0.0323 |
| B | – | 2 | 1/62 = 0.0161 |
| C | 2 | 1 | 1/62 + 1/61 = 0.0325 |
Document C wins, because it ranks near the top of both lists. That is the whole idea of RRF: documents that both methods agree on rise to the top. It is popular because it needs no tuning to start and is robust to the very different score scales.
Score normalisation and weighting
The other approach rescales each list's scores to a common range, for example 0 to 1, and then takes a weighted sum:
final = alpha × vector score + (1 − alpha) × keyword score
Weaviate's hybrid search exposes exactly this alpha setting: 1 means pure vector search, 0 means pure keyword search, and values in between blend the two. Its default fusion method uses relative scores; ranked fusion, which works like RRF, is the alternative. OpenSearch offers similar normalisation steps in its search pipelines.
Score-based fusion keeps more information than ranks alone. If the top keyword result is far ahead of the rest, that gap survives. The cost is that you need to tune the weight on your own data.
Where You Can Use Hybrid Search
Most search and vector databases now support hybrid search in some form:
- Elasticsearch and OpenSearch: BM25 is built in; both can combine it with vector (kNN) queries and fuse results.
- Weaviate: a single hybrid query with the
alphaweight and a choice of fusion method. - Qdrant: its Query API runs several sub-queries ("prefetch"), such as a dense vector search and a sparse vector search, then fuses them with RRF or distribution-based score fusion.
- Pinecone and others: support sparse vectors alongside dense ones, so keyword-style and meaning-style signals can be searched together.
- PostgreSQL: combine built-in full-text search with the pgvector extension and fuse the two result lists in SQL.
You will also see learned sparse vectors (models such as SPLADE). They act like a smarter keyword search: they keep exact-term matching but also add related words the document didn't contain. They can replace BM25 as the keyword half of a hybrid setup.
How to Tune Hybrid Search
Defaults are a fine start, but tuning on your own queries makes the real difference.
- Build a small test set. Write down 30 to 100 real queries and the documents that should come back for each. Include exact-code queries, vague questions and a few with typos.
- Measure each half alone first. Run keyword-only and vector-only and note which queries each one gets right. This tells you what hybrid search needs to fix.
- Start with RRF. It rarely does badly. Then try weighted fusion and compare.
- Adjust the weight to your users. Technical products with lots of codes and part numbers usually lean towards keyword search. Natural-language questions lean towards vector search.
- Retrieve more than you show. Fetch, say, the top 50 from each method before fusing, then show the top 10. A document ranked 30th by one method can still win after fusion.
- Add a reranker if needed. A cross-encoder reranker can re-score the fused top results with a heavier model. It costs latency but often sharpens the final order.
- Re-test when content changes. New document types or a new embedding model can shift the best settings.
When Hybrid Search Is Not Worth It
Hybrid search adds a second index, more moving parts and more latency. Skip it when:
- Queries are almost always exact. Searching log lines, SKUs or legal citations works well with keyword search alone.
- The collection is tiny. With a few hundred short documents, either method alone may be good enough.
- Users always ask in full sentences about general topics. Pure vector search might be fine, though a quick test is cheap.
For most real systems, especially RAG pipelines that feed retrieved text to an LLM, the gain is worth it. Missing the one document that contains the exact answer is the most common reason a RAG answer goes wrong.
FAQ
What is hybrid search in simple terms?
Hybrid search runs a keyword search and a vector (meaning-based) search at the same time and merges both result lists into one ranking. You get exact matches for names and codes plus results that match the meaning of the query, even with different wording.
Is hybrid search better than semantic search?
Usually, yes, on real-world queries. Semantic search alone often misses exact terms such as product codes, names and rare jargon. Adding a keyword search fixes those misses while keeping the meaning-based results, so hybrid search tends to retrieve the right document more often.
What is reciprocal rank fusion?
Reciprocal rank fusion (RRF) merges ranked lists using only positions, not raw scores. Each document gets 1 divided by (k plus its rank) from every list it appears in, and those values are added up. Documents that rank well in both lists end up on top. The constant k is usually 60.
Do I still need BM25 if I have embeddings?
In most cases it helps. BM25 is cheap, needs no model and is very precise for exact words. Embeddings handle meaning. Combining them almost always beats either one alone, especially for queries with codes, names or new terms the embedding model never learned.
How do I choose the alpha weight?
Start in the middle or use RRF, then test on a set of real queries with known good answers. If exact-term queries fail, move the weight towards keyword search. If paraphrased questions fail, move it towards vector search. Pick the value that gets the most queries right.