LESSON 48 · RETRIEVAL

Hybrid Search

Learn how hybrid search combines keyword-based retrieval with semantic vector search to find both exact matches and meaning-based matches.

30 min read•Intermediate•Generative AI

By the end of this lesson, you will be able to:

  • Explain hybrid search.
  • Understand why keyword and semantic search complement each other.
  • Compare lexical, vector, and hybrid retrieval.
  • Understand score combination and result fusion.
  • Build a simple Python hybrid-ranking example.
  • Use metadata filtering with hybrid retrieval.
  • Evaluate hybrid search for RAG.
1

What Is Hybrid Search?

Hybrid search combines lexical search, which looks for matching words or terms, with semantic search, which uses embeddings to find related meaning.

Simple idea:Use lexical search for exact signals, vector search for meaning, then combine their evidence into a stronger ranking.
EXAMPLE 1Exact identifier

A search for SKU-XJ42 should strongly favor a document containing that exact product code.

EXAMPLE 2Different wording

“How can I get my money back?” can retrieve a document about the “refund process” even when the words differ.

2

Why Combine Two Search Methods?

Keyword search
  • Strong for exact words
  • Good for IDs and names
  • Can miss related wording
Semantic search
  • Strong for meaning
  • Handles paraphrases
  • Can be weaker on exact identifiers

Hybrid search keeps useful signals from both retrieval approaches.

3

How Hybrid Search Works

User query“Refund for SKU-XJ42”
→
Lexical searchFind exact terms
+
Vector searchFind related meaning
→
FusionCombine rankings

The final results can then be filtered, reranked, or limited with Top-K.

4

Lexical Search

STRENGTH

Exact terms

Excellent for product codes, names, error messages, and distinctive phrases.

STRENGTH

Rare terms

Unusual words can strongly identify a document.

LIMIT

Paraphrases

Different wording may fail to produce a strong lexical match.

LIMIT

Meaning

Word matching alone does not fully capture semantic relationships.

Common lexical approaches include inverted indexes and relevance algorithms such as BM25.

5

Semantic Vector Search

Semantic retrieval converts queries and chunks into embeddings and searches for vectors that are close under a selected metric.

LEXICAL

Words

“cancel subscription” favors matching terms.

+
SEMANTIC

Meaning

“stop my membership” can retrieve the same concept.

6

Combining Search Scores

One simple approach is to normalize comparable signals and combine them with weights.

</> Python
keyword_score = 0.80
semantic_score = 0.70

keyword_weight = 0.45
semantic_weight = 0.55

hybrid_score = (
    keyword_weight * keyword_score
    + semantic_weight * semantic_score
)

print(round(hybrid_score, 3))

This is a teaching example. Production systems must account for the different score scales and meanings of their retrievers.

7

Why Score Normalization Matters

Lexical and vector systems may produce scores with different ranges. Adding raw scores directly can make one signal dominate.

BADRaw score addition

Add unrelated score scales without checking their distributions.

BETTERNormalize or fuse ranks

Use normalization or a ranking-fusion method and validate it on real queries.

Important:Do not assume a lexical score of 0.8 and a vector score of 0.8 mean the same thing.
8

Rank Fusion with RRF

Reciprocal Rank Fusion (RRF) combines ranked lists without requiring raw scores to use the same scale.

</> Python
def rrf_score(rank, k=60):
    return 1 / (k + rank)

keyword_rank = 2
semantic_rank = 4

score = rrf_score(keyword_rank) + rrf_score(semantic_rank)

print(round(score, 5))

A document appearing high in both lists receives contributions from both rankings.

9

Hybrid Search + Top-K

QueryUser question
→
RetrieversLexical + semantic
→
FusionCombine candidates
→
Top-KSelect final results

Hybrid retrieval can merge candidates, rank them, and keep the final Top-K results.

10

Hybrid Search + Metadata Filtering

Constraintsregion = US
→
LexicalExact terms
+
SemanticRelated meaning
→
Final rankingAllowed relevant results

A support system can restrict results to the correct product and region while using both retrieval signals.

11

Simple Python Candidate Fusion

</> Python
keyword_results = ["A", "B", "C"]
semantic_results = ["C", "A", "D"]

combined = []

for item in keyword_results + semantic_results:
    if item not in combined:
        combined.append(item)

print(combined)

A production implementation should use a formal fusion method and preserve ranks or scores for evaluation.

12

Hybrid Search in RAG

1. QueryUser asks
→
2. RetrieveKeyword + vector
→
3. FuseCombine evidence
→
4. GenerateLLM uses context

Hybrid retrieval is useful for enterprise content where questions mix natural language with exact terms, codes, names, or identifiers.

13

When Hybrid Search Works Well

01Product catalogs

Users may search with SKUs and descriptions.

02Technical docs

Error codes and API names benefit from lexical matching.

03Enterprise knowledge

Employees mix exact internal terms with natural-language questions.

04Policies

Exact clause terms and broader meaning can both matter.

05Support systems

Ticket IDs and product names coexist with conversational questions.

06RAG applications

Combining signals can improve coverage for mixed query types.

14

When Hybrid Search May Not Be Necessary

Semantic search may be enough
  • Queries are mostly natural language
  • Exact identifiers are uncommon
  • Evaluation shows strong retrieval
Hybrid is worth testing
  • Exact terms matter
  • Paraphrases are common
  • One retriever misses useful evidence

Hybrid retrieval adds complexity, so justify it with measured improvement.

15

Common Hybrid Search Mistakes

01Adding raw scores

Different scales can make one retriever dominate.

02Assuming hybrid is always better

Evaluate before adding complexity.

03Ignoring duplicates

The same chunk can appear in both lists.

04Weak lexical search

Analyzers and field choices affect lexical quality.

05Ignoring metadata

Hybrid retrieval still needs correct constraints.

06Skipping evaluation

Measure whether combined retrieval improves useful evidence.

16

Evaluate Hybrid Search

RECALL@KDoes evidence appear in the retrieved set?
PRECISION@KHow much retrieved context is useful?
RANKDoes useful evidence move higher?
LATENCYDoes the second retriever add delay?
ANSWER QUALITYDoes hybrid improve grounded answers?
COSTIs the improvement worth extra retrieval work?
Best practice: compare lexical-only, semantic-only, and hybrid retrieval on the same evaluation set.
17

Practice: Build a Hybrid Ranking

Create two ranked lists of document IDs. Give each document a lexical rank and a semantic rank, then use RRF to produce a combined ranking.

TASK

Compare the two retrievers

Find documents appearing in both lists and see how their combined rank changes.

Quick Quiz

1. What is hybrid search?

It combines lexical retrieval and semantic vector retrieval.

2. Why is keyword search useful?

It is strong for exact terms such as product codes, names, and identifiers.

3. Why should raw scores be handled carefully?

The two retrievers may use different score scales and meanings.

4. What is RRF?

Reciprocal Rank Fusion combines ranked lists without requiring their raw scores to share a scale.

30-Second Recap

1. Lexical

Find exact words and identifiers.

2. Semantic

Find related meaning using vectors.

3. Fuse

Combine retrieval signals or ranked lists.

4. Evaluate

Measure quality, latency, and cost.

Key Takeaways

  • Hybrid search combines lexical and semantic retrieval.
  • Lexical search is strong for exact terms; semantic search is strong for meaning and paraphrases.
  • Score fusion requires compatible signals, normalization, or rank fusion.
  • RRF is one practical ranking-fusion method.
  • Metadata filtering can work alongside hybrid retrieval.
  • Hybrid search adds complexity, so evaluate it against simpler baselines.
  • Compare lexical-only, semantic-only, and hybrid retrieval on the same test set.