Vector Databases
Advanced 14 min read Vector Databases

Hybrid Search

Words AND meaning together

Vector search misses exact strings and rare tokens that lexical search nails, and vice versa. Hybrid search — combining BM25-style keyword with vector — covers both, and its success depends on fusion and weighting.

hybrid searchBM25lexicalfusionRRFkeywordweighting
Prerequisites: Similarity Search
Before we start

What you will learn

  • Explain BM25's and vector search's complementary strengths
  • Combine retriever scores with RRF or weighted fusion
  • Tune fusion settings deliberately
Introduction

What is this?

Hybrid search runs a lexical retriever (BM25-like) and a vector retriever over the same corpus, then fuses the two ranked lists into one — via Reciprocal Rank Fusion (RRF) or weighted score blending. Synonyms (vector wins) and exact identifiers (lexical wins) both retrieve correctly; the fusion knob decides which voice dominates.

Motivation

Why do you need it?

  • Code, SKUs and error codes are lexical: vector search mangles exact strings.
  • Paraphrase and intent are semantic: BM25 misses them.
  • Hybrid reliably beats either retriever alone on mixed corpora.
  • RRF is robust and tuning-light; weighted blending gives finer control (at the risk of calibration pain).
Think about it

Mental model

Imagine

Two scouts reporting back

Think of

Hybrid fusion

Scout A reads literally (finds your exact slogan), Scout B reads pragmatically (finds the rival that means the same). Neither always spots everything, so the leader merges their ranked shortlists, counting each 'place' — a scout placing 3rd plus the other placing 5th often beats a single scout's 2nd-place-only report.

Mechanics

How it works

  • Index: store original text/fields for lexical search AND embed vectors.
  • Query: run lexical on the text and vector on the embedding in parallel.
  • Fusion: RRF sums 1/(k+rank) over both lists; weighted fusion blends normalized scores.
  • K (RRF) default ~60, then paper-average results close to optimal with zero tuning.
  • Optional: metadata filters apply to both retrievers consistently.

Two retrievers, one ranked list.

Query
Lexical
Vector
Fuse
Rerank
Real world

In production

  • Enterprise search for code+tickets: exact error strings and conceptual match in one box.
  • RAG pipelines hybrid-retrieve then rerank → fewer missing-truth cases.
  • E-commerce catalogs: product codes (lexical) plus 'similar to the one I liked' (vector).
Guidelines

Best practices

  • Default to RRF unless you have strong reason to blend scores.
  • Ensure metadata filters apply to both retrievers identically.
  • Keep source text indexed for lexical — vector-only stores can't do hybrid.
  • Benchmark hybrid vs each retriever separately on your eval set before trusting the sandwich.
Watch out

Common mistakes

  • Fusing lists from different corpus snapshots (stale mismatch).
  • Normalizing scores differently per retriever then blending — double-counted strengths.
  • Assuming hybrid automatically beats single retrievers; verify per task.
Root cause analysis

Common issues

Error
Hybrid misses a query each single-armed retriever handled
Root cause

Fusion or filter mismatch

Fix

Check filter parity and fusion denominators; test retrievers isolated first.

Error
RRF floods vectors with lexical noise
Root cause

Small k (like 1-10) over-weighted

Fix

Use k~60 and re-benchmark with k sweep.

When things break

Debugging tips

  • Exact-code queries missing → lexical part has no source-text index or analyzer broke tokens.
  • Heavy synonym dependence misses → vector weight too low in blending.
  • Duplicated hits from both retrievers → dedupe keys before fusion (union by id).
Interviews

Interview checkpoint

Practice

Hands-on lab

Keyword Plus Semantic Blending
30 min · intermediate
In progress
Objectives
  • Compute a simple term-frequency keyword score
  • Smooth it with an inverse document frequency
  • Blend keyword and semantic scores and compare rankings

Keyword Plus Semantic Blending

30 min · intermediate

0/3 steps
0%
sandbox · Linux sandbox
$
Try these commands
Test yourself

Quick quiz

0/2
1

Reciprocal Rank Fusion (RRF) combines documents by…

2

BM25 excels at synonym matches.

Go deeper

Official documentation