Skip to content

Chapter 2.7 — Hybrid search, reranking and metadata filtering

🎯 Objective

Show why pure vector search is rarely enough in corporate production and how hybrid search + reranking + metadata filtering, together, form the defensible retrieval pipeline that appears in almost every mature RAG.

Vector search captures semantic similarity ("contract with an early termination clause" is close to "how to cancel the contract"), but it tends to fail when the query depends on literal strings: product names, error codes, SKUs, internal acronyms, version numbers.

BM25 and lexical variants solve exactly that case: high precision in term matching.

Hybrid search combines the two and fuses the ranking. The most common strategies:

  • Linear combination. score = α · score_vec + (1−α) · score_bm25, with α calibrated on a golden set.
  • Reciprocal Rank Fusion (RRF). Combines rankings, not scores: insensitive to different scales, it is the sensible default in most cases.
  • Late fusion with a reranker. Separate searches, union of the top-k from each, and a cross-encoder reranker decides.
When hybrid helps When hybrid is wasted
Corpus with a lot of technical jargon, acronyms, codes Uniform free text in a single language
Queries that mix natural language with literal terms Purely semantic queries
Regulated domains where the exact term matters Small, homogeneous corpus
Multilingual with a shared glossary Domains where BM25 alone already saturates

🧠 Reranking

Reranking reorders the initial top-k using a model that is more expensive and more precise than the retriever. The dominant pattern is the cross-encoder: the model reads the query and the document together, instead of comparing independent embeddings.

Typical production pipeline:

query -> retrieval top 50–100 -> metadata filter (mandatory) ->
reranker top 5–10 -> context builder -> LLM

Operational notes:

  • A weak reranker is worse than no reranker. Measure and compare with and without the reranker on a golden set before promoting it.
  • Latency and cost grow. The reranker runs over all candidates, not just the winners; a top-50 with a cross-encoder reranker is typically the largest latency consumer in RAG.
  • A reranker compensates for part of the embedding's weakness, but it does not solve missing filters or bad chunking. It is the last capsule in the stack, not the first.

🧠 Metadata filtering

Mandatory filters in enterprise RAG:

  • tenant_id.
  • language.
  • jurisdiction / region.
  • confidentiality_level.
  • product / version.
  • valid_from / valid_until (freshness).

Principles:

  • Filters are applied in storage, before the reranker, before the prompt. When the vector DB or search engine receives the query, it already knows there is a set of non-negotiable filters.
  • A filter failure must be explicit. A query without tenant_id should be rejected, not treated as "all tenants".
  • Filters do not replace isolation. For very sensitive tenants, separate indexes or distinct collections are preferable to filters over a shared index.

🔁 Query-side techniques: rewriting, multi-query and HyDE

Hybrid search and reranking act on the index and the candidates. A third family acts on the query, before the search. The most used:

Technique What it does Cost When it helps When it hurts
Query rewriting An LLM reformulates the question: expands acronyms, removes conversational noise, makes the question self-contained from the history 1 short call Multi-turn chat; poorly formulated questions; user vocabulary different from corpus vocabulary Questions that are already precise. In a study with a strong embedder, rewriting and decomposition worsened nDCG@10
Multi-query Generates N variations, searches each one and fuses the rankings (RRF) N searches + fusion Broad or ambiguous questions; low recall due to formulation Cost multiplied by N; may dilute precision. The original proposal (RAG-Fusion) was evaluated manually, in a single domain
Step-back / decomposition Asks a more general question, or splits into sub-questions, before searching 1–2 calls Multi-hop and comparative questions Step-back is a reasoning technique; using it as retrieval is an extrapolation
HyDE (Hypothetical Document Embeddings) An LLM writes a hypothetical document that would answer the question; the embedding of that document (mean of N samples plus the query embedding) is used for the search 1 generation + 1 embedding per query Zero-shot dense retrieval without relevance labels; short queries against long documents; specialized domain outside the retriever's training Domains where the LLM cannot write a plausible document (it hallucinates in the wrong direction), rare entities, recent facts. With a fine-tuned encoder or a strong reranker, the gain shrinks or turns into a loss

HyDE mechanism and evidence. In the original paper (ACL 2023), with an unsupervised contrastive encoder, HyDE raised nDCG@10 on TREC DL19 from 44.5 to 61.3, comparable to supervised retrievers; but it lost to the fine-tuned version of the same encoder on several datasets, and a weak generator LLM degraded the fine-tuned encoder. In an independent 2024 study with a strong embedder, HyDE added about 5 nDCG@10 points at the cost of 2.5–3× the retrieval latency, and a single pseudo-document was enough (more documents only increased latency); in clinical QA, the gains were not statistically significant. In tooling, one popular framework's HyDE implementation already lives in a legacy package, and another's documentation records two failure modes: an ambiguous query without context, and bias on open-ended questions.

Editorial stance. Treat query-side techniques as hypotheses to measure on your golden set, not as mandatory steps. They compete with cheaper alternatives (BM25 in hybrid search, metadata, reranker) and with an indexing alternative (contextual retrieval, below). The right question is "how much recall@k do I gain per additional millisecond and cent?", and the answer varies by corpus. Record in tracing which transformation was applied to each query (Ch. 5.3); without it, a recall regression has no identifiable cause.

🧭 What else exists

Techniques from 2021–2025 worth knowing, with maturity declared:

  • Contextual retrieval (practice published in 2024, with the author's internal benchmark). Before embedding and indexing in BM25, an LLM writes 50–100 tokens of context for each chunk from the whole document. In the published measurements, the top-20 failure rate fell 49% with contextual BM25 and 67% when adding reranking. It is an indexing technique (one-off, offline cost), orthogonal to query-side techniques. The same source gives a rule of thumb: below ~200k tokens, put the whole corpus in the prompt instead of building RAG (see Ch. 2.10).
  • Late chunking (paper, 2024–2025). Embeds the whole document with a long-context model and splits into chunks after the transformer and before pooling, so each chunk carries document context. Works without additional training.
  • Late interaction (papers; ColBERTv2, NAACL 2022; ColPali, ICLR 2025). Keeps one vector per token and scores by MaxSim; ColBERTv2's residual compression shrinks the index 6–10×. ColPali applies the idea to page images, without OCR, and is today the reference approach for visually rich documents. Cost: a larger index and more expensive scoring. It has not been shown to replace OCR in every case.
  • Learned sparse retrieval (paper, 2021; SPLADE v2). A model learns sparse vectors over the vocabulary, indexable in an ordinary inverted index, with reported gains over BM25. An alternative to pure lexical search inside hybrid search.
  • Semantic chunking (contrary evidence, 2024). In a systematic evaluation, the computational costs of semantic chunking were not justified by consistent gains; on realistic data, fixed-size chunking won in document retrieval. Fixed chunking with overlap remains a solid baseline.
  • MMTEB (benchmark, 2025). More than 500 tasks in more than 250 languages. The best public model was a 560M-parameter instruction-tuned model (multilingual-e5-large-instruct); embedders based on multi-billion-parameter LLMs lead only in some subsets. Use it to choose an embedder by language and task, not by size.

🚨 Classic failure modes

  • Hybrid search without calibration: a high lexical weight degrades semantic queries and vice versa.
  • A reranker trained on another domain: it prioritizes irrelevant patterns.
  • Metadata applied after the retriever: the top-k comes contaminated by other tenants and the filter only cleans the residue.
  • Filters based on text fields without normalization: pt-BR and pt_br become different tenants.

📌 Checklist

  • [ ] Are BM25 + vector combined via RRF or calibrated linear fusion?
  • [ ] Was the reranker evaluated against "no reranker" on a golden set?
  • [ ] Do tenant/language/jurisdiction filters run in storage, not in the prompt?
  • [ ] Is a query without mandatory filters explicitly rejected?
  • [ ] Are the reranker's latency and cost monitored at p95?

📚 References