Hybrid Search (Keyword + Vector)
Part of the AI Engineer Roadmap
In short
Vector search understands meaning but can miss exact terms like 'CS3401' or 'Section 80C'. Keyword search nails exact terms but misses synonyms. Hybrid search runs both and merges the results.
Combining traditional keyword search (BM25) with vector similarity search — often outperforms either method alone, especially for queries with exact terms like product codes or names.

Think of it like this
Finding a friend at the station
Looking for a friend on a crowded platform, you shout her name on a megaphone and also hold up her photo. The name catches her if she hears it. The photo helps people who recognise her face. Keyword search is the name, vector search is the photo.
Watch it happen
One query, two searches, one list
1/5Query: 'CS3401 syllabus for compiler design'.
The big ideas
What you need to know
BM25 for exact terms
A classic keyword ranking method. Great for codes, names, rare words and acronyms.
Vectors for meaning
Catches paraphrases and synonyms, and handles questions phrased very differently from the text.
Fuse by rank
RRF gives each doc 1/(k + rank) from each list and adds them. A k around 60 is a common default.
Built into many tools
Weaviate, Elasticsearch, OpenSearch and others support hybrid search directly.
See it in code
Walk through the code
1def rrf(keyword_ids: list[str], vector_ids: list[str], k: int = 60) -> list[str]:2 scores: dict[str, float] = {}3 for ranking in (keyword_ids, vector_ids):4 for rank, doc_id in enumerate(ranking, start=1):5 scores[doc_id] = scores.get(doc_id, 0) + 1 / (k + rank)6 return sorted(scores, key=scores.get, reverse=True)7 8kw = ["d7", "d2", "d9"] # from BM259vec = ["d2", "d4", "d7"] # from vector search10print(rrf(kw, vec)) # ['d2', 'd7', 'd4', 'd9']1/3Each document earns 1/(k + rank) from every list it appears in.
Reciprocal Rank Fusion in a few lines. d2 and d7 appear in both lists, so they win.
Save yourself the pain
Common mistakes
Oops
Adding BM25 scores and cosine scores directly.
Do this instead
They're on different scales. Fuse by rank with RRF, or normalise scores first.
Oops
Assuming vector search alone handles product codes and IDs.
Do this instead
Test queries with exact codes. If they fail, add keyword search.
Your mission
Hybrid on your notes
Quick check
A user searches 'Section 80C deduction'. Vector search returns general tax articles but misses the exact section. What helps most?
Go deeper
- 1Implement hybrid search combining BM25 and vector similarity scores.
- 2Test on queries where keyword search wins (exact terms) vs. where semantic search wins (paraphrased queries).
- 3Learn common score-fusion techniques (e.g. reciprocal rank fusion).
More topics at this stop
Stuck on this topic? Ask an Insider
Get 1:1 guidance from people who've walked this exact path — on the InsideEdge app.