Skip to main content
Hybrid retrieval combines dense semantic embeddings with sparse lexical embeddings to improve robustness across both natural-language queries and keyword-precise queries. When one signal is weak, the other compensates.

How it works

1

Dual indexing

Each document is embedded twice — once with a dense SentenceTransformers model (SentenceTransformersDocumentEmbedder) to produce a float vector capturing semantic meaning, and once with a sparse SentenceTransformers model (SentenceTransformersSparseDocumentEmbedder, typically a SPLADE model) to produce a token-weight sparse vector capturing lexical features.
2

Dual retrieval

At query time, the query is embedded with both the dense text embedder and the sparse text embedder to produce two query representations.
3

Score fusion

Results from the dense retriever and the sparse retriever are merged using ResultMerger (from utils/fusion.py). The default strategy is Reciprocal Rank Fusion (RRF), which combines rankings without requiring score normalization.
4

Final ranking

The fused, deduplicated result list is returned as the top-k documents.

RRF formula

Where the sum is over all retrieval sources and k (default 60) smooths rank differences.

Pinecone hybrid indexing example

src/vectordb/haystack/hybrid_indexing/indexing/pinecone.py

Pinecone hybrid search example

src/vectordb/haystack/hybrid_indexing/search/pinecone.py

Result fusion with RRF

For backends without native hybrid support, use ResultMerger:
src/vectordb/haystack/components/result_merger.py

Configuration

When to use it

Corpora with mixed query styles: some users ask in natural language, others search with domain keywords or acronyms
Enterprise knowledge bases where exact product names, codes, or identifiers matter alongside conceptual questions
Any workload where pure semantic search misses highly relevant documents that contain exact query terms

When not to use it

Small datasets where the added complexity of dual indexing and fusion has negligible quality impact
Prototypes or early experiments where you have not yet validated whether the semantic baseline falls short

Settings to tune first

Common pitfalls

Unbalanced fusion: Setting one weight to near-zero effectively reverts to single-signal retrieval. Measure both retrieval paths independently before fusing.
Missing sparse vectors at query time: If the indexing config uses sparse embeddings but the search config does not, the sparse retrieval path returns nothing. Keep configs consistent.
Not validating per-query-class behavior: Hybrid usually helps keyword queries most and natural-language queries least. If your evaluation set is exclusively natural-language questions, the improvement over semantic search may be small.

Supported backends

Chroma, Milvus, Pinecone, Qdrant, Weaviate.

Dataset configs provided

ARC, Earnings Calls, FActScore, PopQA, TriviaQA.

Next steps

Components

Add reranking after fusion for further precision improvement

Pipelines

Learn about advanced pipeline composition patterns