Hybrid search vs vector search is the first retrieval decision you make after you split your documents into chunks. Vector search finds text that means the same thing. Keyword search finds text that contains the same word. Production RAG needs both kinds of match, and most weak RAG answers I have seen start with a retriever that only does one of them.

This guide explains where each method wins, how reciprocal rank fusion (RRF) combines them, how to build it in Postgres, and what a small test on my own site taught me. If you are new to the topic, read What Is RAG? Retrieval-Augmented Generation first.

Hybrid search vs vector search: quick answer

  • Use vector search when users describe a need in their own words and your documents use different words.
  • Use keyword search (BM25 or Postgres full-text) when users type exact names, error codes, version numbers, or product terms.
  • Use hybrid search when both kinds of queries hit the same index, which is almost every real RAG app.
  • Measure on your own queries before you trust any benchmark, including mine.

What vector search is good at

A vector search turns the query and every chunk into embeddings, then returns the chunks whose vectors are closest. It handles paraphrase well. A user who asks "how do I stop my bot from breaking when the AI provider goes down" can match a chunk titled "LLM fallback during model outages" even though the two texts share almost no words.

Vector search is weaker in three places:

  1. Exact tokens. Error codes like ECONNRESET, versions like 2.45, or a rare product name can land far from the query in embedding space, because the model has seen them rarely.
  2. Negation and qualifiers. "Without Redis" and "with Redis" often produce very similar vectors.
  3. Explainability. When a result looks wrong, it is hard to say why a vector was close.

What keyword search is good at

Keyword search scores chunks by the words they contain. BM25 is the classic scoring function: it rewards a term that is rare across your corpus and frequent in the chunk, and it softens the effect of very long chunks. In Postgres, ts_rank and ts_rank_cd give you a similar full-text score, and websearch_to_tsquery parses a plain user query safely.

Keyword search wins on the exact-term cases above. It loses when the user and the document use different vocabulary. It cannot connect "bot" with "chatbot" or "provider outage" with "model downtime" unless you add synonyms by hand.

Why hybrid search exists

The two methods fail on different queries. That is the whole argument for hybrid search: if the failures do not overlap, a combined list should recover more correct chunks in the top results than either list alone.

There is a catch. The two retrievers give scores on different scales. A BM25 score of 14.2 and a cosine similarity of 0.81 cannot be added or averaged without careful normalization. This is why most teams fuse by rank instead of by score.

Reciprocal rank fusion in one formula

RRF was published by Cormack, Clarke and Buettcher at SIGIR 2009. For each document, you add up 1 / (k + rank) across every ranked list it appears in. The paper used k = 60. A document that is near the top of both lists wins. A document that is first in only one list can still make the final top results.

python
def rrf(rankings, k=60):
    """rankings: list of lists of doc ids, best first."""
    scores = {}
    for ranking in rankings:
        for position, doc_id in enumerate(ranking, start=1):
            scores[doc_id] = scores.get(doc_id, 0) + 1 / (k + position)
    return sorted(scores, key=scores.get, reverse=True)

final_ids = rrf([bm25_ids[:50], vector_ids[:50]])[:10]

Why teams like RRF:

  • No score normalization is needed.
  • It has one tuning knob, k, and the default works for most corpora.
  • It is easy to extend to a third list, such as a recency or metadata filter list.

Its weakness is that it treats both lists as equally trustworthy. If one retriever is much worse than the other, equal weighting drags the final list down. You can weight the lists, but then you have a tuning problem and need an evaluation set to solve it.

Build it in Postgres with pgvector

If your data is already in Postgres, you can run both retrievers in one query. This version assumes a chunks table with a tsv column (a tsvector) and an embedding column (pgvector).

sql
WITH fts AS (
  SELECT id,
         ROW_NUMBER() OVER (ORDER BY ts_rank_cd(tsv, q) DESC) AS rnk
  FROM chunks, websearch_to_tsquery('english', :query) AS q
  WHERE tsv @@ q
  ORDER BY ts_rank_cd(tsv, q) DESC
  LIMIT 50
),
vec AS (
  SELECT id,
         ROW_NUMBER() OVER (ORDER BY embedding <=> :query_embedding) AS rnk
  FROM chunks
  ORDER BY embedding <=> :query_embedding
  LIMIT 50
)
SELECT COALESCE(fts.id, vec.id) AS id,
       COALESCE(1.0 / (60 + fts.rnk), 0) + COALESCE(1.0 / (60 + vec.rnk), 0) AS rrf_score
FROM fts
FULL OUTER JOIN vec ON fts.id = vec.id
ORDER BY rrf_score DESC
LIMIT 10;

Things to check before you ship this:

  • Add a GIN index on tsv and an approximate index (HNSW or IVFFlat) on embedding, or both branches will scan the whole table.
  • Use the same language configuration for indexing and querying ('english' above).
  • Keep the per-branch LIMIT at 30 to 100. Fusing only the top 5 from each list throws away most of what RRF can do.
  • Filter by metadata (tenant, language, date) inside both branches, not after the join.

If you use a dedicated vector database, check whether it ships fusion built in. Qdrant, for example, documents hybrid queries with a prefetch step and an RRF fusion step, so you do not have to merge lists in application code.

A small test I ran on my own articles

I wanted to see the difference on real text, so I ran a small, honest test. It is too small to prove anything general, and I say why below.

Setup

  • Corpus: 45 published BuildWithJIT articles. Each document was the title, meta description and H1.
  • 12 queries: 6 exact-term queries (such as HMAC, barge-in, n8n 2.45, Kokoro) and 6 paraphrase queries written the way a reader would describe the problem.
  • For each query I marked one article as the correct answer. A query counted as a hit if that article appeared in the top 3.
  • Methods: BM25 (rank_bm25), a vector retriever, and RRF over the two lists with k = 60.

Important limit: I could not download a neural embedding model in my test environment, so the "vector" retriever was classic LSA (TF-IDF reduced to 20 dimensions with SVD). That is a real vector method, but it is much weaker than a modern embedding model. Do not read these numbers as a verdict on neural embeddings.

Results (top-3 hit rate)

Query typeQueriesBM25LSA vectorsRRF (both)
Exact term66/66/66/6
Paraphrase65/63/63/6
All1211/129/129/12

What I took from it

  1. On exact-term queries every method worked, because the corpus is small and the terms are distinctive.
  2. On paraphrase queries BM25 was better than my weak vector retriever, which surprised me. Titles and descriptions already repeat the key words people use.
  3. RRF did not rescue the weaker list. It matched the weaker retriever. Fusion helps when both lists are decent and fail on different queries. It does not fix a poor retriever.
  4. With 12 queries, one flipped result changes a score by 8 points. Treat this as a method for testing, not as a benchmark.

The practical lesson is to build a small golden set from your own users' questions and measure each retriever first. If a swap from LSA to a real embedding model moves the paraphrase score a lot, you have learned something. If it does not, a simpler keyword index may be enough for your corpus.

How to evaluate your own retriever

You need only three things: queries, the correct chunks for each, and a metric.

  1. Collect 30 to 50 real queries. Use support tickets, chat logs or search logs. Include some exact-term queries and some vague ones.
  2. Label the correct chunk or document for each query by hand. This takes an afternoon and is the most valuable part.
  3. Measure recall@k and MRR. Recall@5 tells you whether the answer reached the model at all. MRR tells you how high it ranked.
  4. Compare three setups: keyword only, vector only, hybrid. Change one thing at a time (chunk size, model, k, list depth).
  5. Re-run after every change to the chunker or embedding model, and keep the numbers in the repo.

This is also where chunking matters most. Chunks that are too long dilute BM25 scores and blur embeddings. Chunks that are too short lose context. The production RAG pipeline guide covers chunking, retries and evaluation in more detail.

Decision table

Your situationStart with
Small corpus, distinctive titles, technical readersKeyword search, then add vectors if misses appear
Support content, users describe problems in their own wordsVector search with a keyword fallback
Product names, SKUs, error codes, versions in queriesHybrid, with keyword weighted at least equally
Multilingual content (for example Hindi and English)Hybrid with a multilingual embedding model, test each language separately
Already on Postgres, under a few million chunkspgvector plus full-text in one query
Need managed fusion and scalingA vector database with built-in hybrid queries

Common mistakes

  • Fusing scores instead of ranks without normalizing them.
  • Taking only the top 5 from each retriever before fusion.
  • Different tokenizers or languages at index time and query time.
  • Skipping the reranker question. A cross-encoder reranker on the top 20 to 50 fused results often adds more quality than tuning the fusion itself. Add it after you have a measured baseline.
  • Judging by three hand-picked queries. Use a labeled set.
  • Treating memory as retrieval. Conversation memory and document retrieval solve different problems; see AI Memory vs RAG: Which Should You Build?.

Where this fits in a real build

In a typical RAG app the order is: ingest and chunk documents, index them twice (full-text and embeddings), retrieve with both, fuse with RRF, optionally rerank, then pass the top chunks to the model with citations. If you are ingesting a website, the RAG FAQ pipeline with sitemap, GPT-4o and Pinecone shows an ingestion flow you can pair with the retrieval step in this guide.

Frequently asked questions

Is hybrid search always better than vector search? No. It is better when both retrievers are reasonably good and fail on different queries. If your corpus is small or your queries are mostly exact terms, keyword search alone can match it. In my small test, fusion matched the weaker retriever instead of beating the stronger one.

What is a good value for k in RRF? The original paper used 60, and it is a safe default. A lower k gives more weight to the very top ranks. Tune it only after you have a labeled evaluation set.

Do I need a vector database for hybrid search? Not necessarily. Postgres with pgvector and full-text search can run both retrievers and the fusion in one query. A dedicated vector database becomes attractive when you need very large scale or built-in fusion.

Should I add a reranker? Often yes, but after you measure recall@k. A reranker can only reorder what the retrievers found. If the right chunk is not in the candidate list, reranking cannot recover it.

Does hybrid search help with Hindi or Gujarati queries? It can, because transliterated words and names often match by keyword even when embeddings are weak. Test each language on its own labeled queries and use an embedding model that supports the language.

Key takeaways

  • Vector search matches meaning. Keyword search matches exact terms. They fail on different queries.
  • RRF fuses ranked lists with 1 / (k + rank) and needs no score normalization.
  • Postgres can run full-text and pgvector search in one query.
  • Fusion cannot rescue a weak retriever. Measure each list before you combine them.
  • A labeled set of 30 to 50 real queries is the most useful asset in any RAG project.
SOURCES & REFERENCES
NEXT IN SERIES

Production RAG Pipeline Architecture: A Practical Guide

Most RAG demos work and most RAG products fail. Here is the full production architecture, the six stages that matter, how to measure quality, and the mistakes that quietly ruin answers.

Continue Reading