What is hybrid search?
What is hybrid search? It runs a full-text query, such as BM25, and a vector query on the same question, then merges the two ranked lists. Full-text search catches exact names and error strings. A vector query can catch the same idea in different words. XERJ can fuse the two arms with reciprocal rank fusion.
TL;DR Hybrid search runs two searches on the same query: a full-text search such as BM25, and a vector search. Each returns a ranked list. A fusion step, often reciprocal rank fusion, merges them into one list.
How hybrid search puts lists together
Match the words
BM25 scores a document by query terms, their frequency, and how rare they are. It is strong when the words in the query appear in the passage.
Match the meaning
A vector query can rank a passage that uses different words for the same idea. XERJ can run this in neural mode; the default embedder is lexical and runs offline.
Reciprocal rank fusion
Each item gets a score of 1 / (k + rank) from each list, and the scores add. The walkthrough on the reciprocal rank fusion page uses a labeled example. XERJ can fuse a lexical arm with a vector arm.
Act as a coding agent. Read https://xerj.org/llms.txt, install XERJ, start a local node, index one folder I point you to, and run one search so I can see a cited passage.
How it works
Full-text search scores a document by the query terms it contains, how often they appear, and how rare they are. It is strong when the words in the query appear in the passage. It misses a passage that says the same thing in different words.
A vector query can rank that paraphrase, because closeness in the vector space does not require shared terms. It is weaker on exact tokens, where two similar identifiers can sit close together.
Hybrid search runs both, then fuses the ranks. Reciprocal rank fusion is a common way to do that without mixing raw scores that sit on different scales. The worked example is on the reciprocal rank fusion page.
How XERJ uses it
XERJ keeps a lexical index and vectors in the same engine. The default embedder is lexical and runs offline. Neural mode adds a trained vector arm. You can fuse a lexical arm with a vector arm in one request.
The how-to, including the request shape and when to use RRF or a weighted sum, is how to run hybrid search in XERJ. A second practical page is how XERJ combines search.
See also BM25, semantic search, and reranking.
History and research
The lexical arm in most hybrid systems is BM25, surveyed by Robertson and Zaragoza in The Probabilistic Relevance Framework: BM25 and Beyond (2009).
Dense vector retrieval for question answering is described by Karpukhin and colleagues in Dense Passage Retrieval for Open-Domain Question Answering (EMNLP 2020).
The usual fusion method is reciprocal rank fusion, introduced by Cormack, Clarke and Buettcher in Reciprocal Rank Fusion outperforms Condorcet and individual Rank Learning Methods (SIGIR 2009). This page does not treat those papers' scores as XERJ measurements.
Guides
Run it yourself with the hybrid search recipe. The hybrid search answer shows one request, and how XERJ combines search explains the merge.
Related terms
BM25, semantic search, reciprocal rank fusion, and hybrid vs vector vs semantic search.
FAQ
What is hybrid search?
It runs a full-text search and a vector search on the same query, then merges the two ranked lists into one list.
Why use two searches instead of one?
The two methods miss different things. Full-text search is strong on exact tokens. A vector query is stronger on paraphrases. Hybrid search keeps both kinds of hits.
How does XERJ run hybrid search?
Start a node with neural embeddings, then send one request that includes a match query and a knn query, with fusion set to rrf. The how-to is the hybrid search answer.
Is this the same as reranking?
No. Hybrid search merges two first-stage lists. Reranking takes one candidate list and reorders it with a slower model. You can use both, in that order.
Related
- Hybrid vs vector vs semantic search
- How to run hybrid search in XERJ
- How does XERJ combine BM25 and kNN?
- BM25 vs vector search
- What is semantic search?
- Reciprocal rank fusion formula
- What is reranking?
- What is syntax-aware search? · same intent: Science
- What is agentic memory? · same intent: Science
- What is context engineering? · same intent: Science