# What Is Hybrid Search?

> What hybrid search is, why keyword and vector search need each other, and how the two lists are merged, explained simply for your AI interview.

**In short:** Hybrid search runs a keyword search (BM25) and a vector search on the same question, then merges both ranked lists into one result set. Microsoft's Azure AI Search merges them with Reciprocal Rank Fusion (RRF). Keyword search catches exact codes that vectors can miss, and vectors catch meaning that keywords miss.

AI and LLM interview question Q123, Retrieval-augmented generation (RAG). Intermediate, very common (our estimate). From Venkat R. Murty's free Interview Kit: https://designervenkat.online/interview/ai/what-is-hybrid-search

## Say it in 30 seconds

Hybrid search runs two searches on the same question. One is keyword search, which finds exact words like a product code. The other is vector search, which finds text with a similar meaning. Each returns a ranked list, and I merge them with Reciprocal Rank Fusion, which ranks by position rather than raw score. In a returns bot, that means an exact model number and a policy about damaged goods both reach the top.

## Say it in 2 minutes

Keyword search and vector search are good at different things. Keyword search, often scored with a method called BM25, looks for the exact words in the question. It is very good with product codes, model numbers and names. Vector search turns text into embeddings, which are lists of numbers that stand for meaning, and finds passages with a similar meaning even when the words differ. It handles questions people phrase in their own way, but it can miss an exact code.

Hybrid search does both at once. The same question goes to both searches, and each returns its own ranked list. Then the two lists are merged. I would not add the raw scores together, because a BM25 score and a vector similarity score sit on different scales. Reciprocal Rank Fusion avoids that problem. It gives each result points based on its position in each list, so a result that ranks well in both lists rises to the top.

Take a returns bot for a home-appliance retailer. A customer types a message about a cracked kettle lid. The keyword search finds the exact manual for that model, and the vector search finds the policy on damaged goods. The merged list shows both, so the bot can answer from the right pages. Before shipping, I would test it on real customer questions and check the top five results, because hybrid search does not win on every set of documents.

It costs more than one search. You store text and vectors for each chunk, and you run two searches per question. But when exact codes and natural questions appear in the same product, it is the first design I would try.

## What is hybrid search, in plain words?

Hybrid search means running two kinds of search on the same question and combining what they find. Hybrid means mixed. Here it means keyword search plus vector search.

Keyword search checks which words a document shares with the question. Its scoring method is BM25, which helps stop common words from dominating the results. Vector search compares meaning. It turns each chunk of text into an embedding and looks for the chunks whose embeddings sit closest to the question's.

Think of a new claims handler at an insurance firm. Some cases she finds by typing the exact claim number. Others she finds by searching for a burst pipe in the kitchen. She uses both, because each finds cases the other misses. Hybrid search does the same in software. Our real case is a support bot that needs both a model number and a plain question.

- **Keyword search:** Finds documents that contain the words, or codes, in the question.
- **BM25:** The scoring formula Azure uses for text search, and a common choice for keyword search.
- **Vector search:** Finds text whose embedding sits close to the embedding of the question.
- **Embedding:** A list of numbers a model produces to stand for the meaning of a piece of text.
- **Reciprocal Rank Fusion:** A simple way to merge ranked lists by position. Written RRF.

## How does hybrid search work?

The two searches start together. The question goes to both, each returns a ranked list, and one merge step turns the two lists into one.

*Diagram, One question, two searches, one merged list: One question goes to two searches at the same time. Each returns its own ranked list, and RRF merges the two into one list that keeps both exact codes and similar-meaning matches.*
1. The question goes to the keyword search.
2. The same question goes to the vector search.
3. Keyword hits reach the merge in rank order.
4. Vector hits reach the merge in rank order.
5. The merged list is what the bot reads.

1. **Run both searches together:** Microsoft's Azure AI Search sends the keyword and vector parts as one request.
2. **Keep each list in order:** Each search returns its own best matches, ranked by its own method.
3. **Merge with RRF:** RRF gives each result points for its position in each list, then adds them up.
4. **Send the top results on:** The bot reads the top few passages, so the merge decides what the model sees.

> **Tip:** Asked how it differs from vector search alone? Say vector search finds meaning, and hybrid adds exact-word search so codes and names are not lost.

## Why not use vector search alone?

Vector search is strong on meaning but weak on rare exact words. An embedding model can miss a rare code, so a general page about the same product can outrank the exact page. Each search fails in a different place, so pairing them covers both gaps.

A customer types "My KX-4410-B kettle lid cracked, can I return it?" into the returns bot. Here is what each search does with that one message.

- **Keyword only: Misses the meaning.** The policy page is titled damaged goods, not lid cracked, so a keyword search ranks it low or misses it.
- **Vector only: Misses the exact code.** It returns kettles in general and can skip the one manual that names KX-4410-B.
- **Hybrid: Gets both.** The model's manual and the damaged-goods policy both reach the top list.

> "Some scenarios, such as querying over product codes, highly specialized jargon, dates, and people's names, perform better with keyword search because it can identify exact matches." (Microsoft, Azure AI Search docs)
>
> "While embedding models excel at capturing semantic relationships, they can miss crucial exact matches." (Anthropic)

## How are the two lists merged?

The obvious idea is to add the two scores. It fails because each search scores on its own scale. A BM25 score has no fixed upper limit, while Azure's vector scores sit between 0 and 1 for Euclidean and dot-product, and between 0.333 and 1.00 for cosine. Adding them mixes two different units.

> "Experiments show the algorithm performs best when you set k to a small value, such as 60." (Microsoft, Azure AI Search docs)

RRF avoids the scales by using position only. A result earns 1 divided by (its rank plus k) for each list it appears in, and the points are added. With k at 60, rank 1 earns about 0.0164 and rank 2 about 0.0161.

```python
# A returns bot's search: a keyword list and a vector list, merged with Reciprocal Rank Fusion (RRF).
K = 60  # RRF's constant; Microsoft's docs say small values such as 60 work best.

keyword = ["KX-4410-B manual", "Returns policy: damaged goods", "Kettle spare parts", "KX-4410 warranty"]
vector = ["Returns policy: damaged goods", "Kettle lid damage guide", "KX-4410-B manual", "Appliance warranty terms"]

def rrf(*ranked_lists):
    scores = {}
    for ranked in ranked_lists:
        for rank, doc in enumerate(ranked, start=1):
            scores[doc] = scores.get(doc, 0) + 1 / (K + rank)
    return sorted(scores.items(), key=lambda item: item[1], reverse=True)

for doc, score in rrf(keyword, vector):
    print(f"{score:.4f}  {doc}")
```

Output:

```text
0.0325  Returns policy: damaged goods
0.0323  KX-4410-B manual
0.0161  Kettle lid damage guide
0.0159  Kettle spare parts
0.0156  KX-4410 warranty
0.0156  Appliance warranty terms
```

In the output, the returns policy comes first by a small margin. It ranks second on keywords and first on vectors. The exact manual ranks first on keywords but third on vectors. So a page that both searches rank well moves to the top.

## How much does it help, and what does it cost?

The evidence supports trying it, but the result depends on your data. BEIR, a 2021 benchmark of 18 public datasets, found plain BM25 a solid starting point. It also noted that dense and sparse models are more efficient but often underperform other approaches.

Anthropic's September 2024 test combined contextual embeddings with contextual BM25 and cut the top-20 retrieval failure rate from 5.7% to 2.9%, a 49% drop. Their method also added a short context note to every chunk before indexing, so the 49% does not show what hybrid search alone would do, and your system may differ.

The costs are real. You store text and vectors for each chunk, run two searches for every question, and tune how the lists are weighted. Microsoft lets you weight the vector side up or down, which is a setting to test on your own questions.

### How would you tune hybrid search for a returns bot?

I would start with about 200 real customer messages, each with the right page labelled. For each one I would check whether the right page lands in the top five. I would measure three setups: keyword only, vector only and hybrid.

If keyword only wins on the model-number messages, I would raise the keyword side's weight for those. If vector only wins on plain-language messages, I would raise the vector side there. The test set decides which way to lean.

## What does the interviewer want to hear?

**A strong answer covers**

- [ ] Two searches, keyword and vector, run on the same question.
- [ ] Keyword search wins on exact codes; vector search wins on meaning.
- [ ] The two lists merge with RRF, which uses positions, not raw scores.
- [ ] Raw scores sit on different scales, so adding them is the wrong merge.
- [ ] Hybrid is a design to test on real questions, and it has a cost.

**Common traps**

- Trap: "Hybrid search just averages the two scores." Better: The scores use different scales. RRF merges by rank position instead.
- Trap: "Hybrid search always beats vector search alone." Better: It can help on mixed questions, but it has a cost. Measure it on your own questions before you claim a win.
- Trap: "Vector search has replaced keyword search." Better: Keyword search still does better on exact codes, names and dates.

## Can you spot the right fix?

**Spot the fix:** A returns bot's vector-only search skips the manual for model KX-4410-B. Which change is most likely to fix that?

A. Add a longer system prompt that tells the model to match model numbers.
B. Add keyword search beside the vector search, and merge the two lists.
C. Lower the temperature so the model repeats the search more carefully.
D. Switch to a larger embedding model and hope it learns model numbers.

**Answer:** B. Exact codes are a keyword job. Adding BM25 beside the vector search covers the codes, and the merge keeps the meaning matches too. Prompts and temperature do not change what the search returns.

**Quick check:** Why does Reciprocal Rank Fusion use positions instead of raw scores?

A. Rank positions turn each score into a whole number, so the merge is exact.
B. Keyword and vector scores sit on different scales, so raw scores cannot be added fairly.
C. Vector search does not produce any scores at all.
D. Positions remove duplicate documents, so the merged list is shorter.

**Answer:** B. Each search uses its own scale. A position means the same thing in both lists, so the merge stays fair without tuning a scale.

## Can you answer these from memory?

**Flash cards**

- **What is hybrid search?** Keyword search and vector search run on one question, and their lists are merged.
- **What does BM25 do?** Scores documents by the exact words they share with the question.
- **What is vector search good at?** Matching meaning, even when the words differ.
- **What is keyword search good at?** Exact codes, model numbers, names and dates.
- **What is RRF?** Merges ranked lists by position: 1 divided by (rank plus k), added up.
- **Why not add raw scores?** BM25 and vector scores sit on different scales, so they cannot be added fairly.

## Likely follow-up questions

- Q124 What is BM25? https://designervenkat.online/interview/ai/what-is-bm25
- Q125 What is reciprocal rank fusion? (full answer coming)
- Q126 Rerankers: cross-encoder vs bi-encoder? https://designervenkat.online/interview/ai/cross-encoder-vs-bi-encoder-rerankers
- Q117 What is a vector database? https://designervenkat.online/interview/ai/what-is-a-vector-database
- Q112 Walk through a RAG pipeline end to end. https://designervenkat.online/interview/ai/rag-pipeline-end-to-end
- Q113 What is chunking, and why does size matter? https://designervenkat.online/interview/ai/what-is-chunking-in-rag

## Learn it in depth

- [Semantic Search](https://designervenkat.online/learn/ai-engineering/semantic-search)
