News / Learn / Embeddings & vector search
What is hybrid search?
You'll be able to explain hybrid search and combine keyword matching with vector search to get better retrieval results.
In plain English
Hybrid search returns results by using two methods at once. One method matches exact words. The other matches meaning. You then merge the two result lists into one ranking. Each method covers the weakness of the other.
Why it matters
Vector search finds text with similar meaning, but it can miss exact terms like product codes, error messages, or names. Keyword search finds exact terms but misses paraphrases. Most products that search documents, help content, or code need both. Hybrid search is a common way to get reliable results from a retrieval step, such as one used in RAG.
How it works
Keyword search, often based on BM25 or a similar scoring method, ranks documents by how often query words appear and how rare those words are across the collection. It is fast and precise for exact terms.
Vector search turns the query and each document chunk into an embedding, then ranks by cosine similarity or a related measure. It handles synonyms and rephrasing well because nearby meanings produce nearby vectors.
A hybrid system runs both searches and gets two ranked lists. It then combines them. A common method is reciprocal rank fusion, which gives each document a score based on its position in each list. Documents that rank well in both lists rise to the top. Another method is a weighted sum of normalized scores, which needs careful scaling because the two score types use different ranges.
After fusion, many systems pass the top results to a reranker, a model that scores query and document pairs more carefully. This step is optional but often improves quality at the cost of extra latency.
A concrete example
A simple reciprocal rank fusion step. Each list gives a rank to every document, and the fused score is the sum of 1 divided by (k plus rank). The constant k is often set to 60.
def reciprocal_rank_fusion(ranked_lists, k=60):
scores = {}
for ranking in ranked_lists:
for rank, doc_id in enumerate(ranking, start=1):
scores[doc_id] = scores.get(doc_id, 0) + 1 / (k + rank)
return sorted(scores, key=scores.get, reverse=True)
keyword_results = ["doc_7", "doc_2", "doc_9"]
vector_results = ["doc_2", "doc_5", "doc_7"]
print(reciprocal_rank_fusion([keyword_results, vector_results]))A short sketch to show the idea. Check the official docs of the tool you use.
What goes wrong
- Adding raw scores from each method BM25 and cosine scores use different scales. Use rank-based fusion, or normalize both score sets before you combine them.
- Skipping keyword search for exact terms Test queries with IDs, codes, and rare names. If vector-only results miss them, add keyword search.
- Ignoring the cost of two searches Running two indexes adds storage, latency, and maintenance. Measure whether the quality gain justifies it for your data.
- No evaluation set Build a small set of real queries with known good answers. Compare keyword only, vector only, and hybrid results before choosing.
Going deeper
Learn BM25 in detail, rank fusion methods, and how rerankers differ from first-stage retrieval. Then study how chunk size affects both search types.
FAQ
Does hybrid search always beat single-method search?
Not always. It usually helps when queries mix exact terms and natural language. If your queries are uniform, one method may be enough. Test with your own data.
Do I need a vector database for hybrid search?
No. You can run both searches in one search engine or in separate indexes. Some databases offer both methods built in, which simplifies the setup.
What is reciprocal rank fusion?
It is a way to merge ranked lists by giving each document a score based on its position in each list. It needs no score normalization, which makes it simple and robust.
Where does a reranker fit in?
It runs after the hybrid search returns candidates. It rescores the top results more precisely. It adds latency, so use it when quality matters more than speed.
Written with AI by CapyLaunch. Spotted a mistake? Email hello@capylaunch.com.