SCIENCE · RETRIEVAL

What is hybrid search?

AUTHOR · XERJ documentation team · REVIEWED BY · XERJ engineering team · PUBLISHED · 2026-11-13 · UPDATED · 2026-11-20
SHORT ANSWER · UPDATED 2026-11-20

What is hybrid search? It runs a BM25 full-text query and a vector query on the same question, then fuses the two ranked lists into one, usually with reciprocal rank fusion. BM25 catches exact names, codes and error strings; vectors catch the same idea in other words. For RAG and AI agents it is the safer default retrieval.

TL;DR Hybrid search runs two searches on the same query: a BM25 full-text search and a vector search. Each returns a ranked list, and a fusion step, usually reciprocal rank fusion, merges them into one. Exact names and close meanings both rank, which is why it is the common default for RAG and AI agents.

PASTE THIS TO YOUR AI AGENT. IT DOES THE REST Act as a coding agent. Read https://xerj.org/llms.txt, install XERJ, start a local node with --embed-mode neural, index one folder I point you to with xerj autoindex, then answer one of my questions with a hybrid query (match plus knn, fusion type rrf, k 60). Show the top 5 passages with file paths, and mark which ones BM25 alone or vectors alone would have missed.
RUN THIS XERJ COMMAND curl -fsSL https://xerj.org/get | sh Install the single XERJ binary.
RUN THIS XERJ COMMAND xerj --embed-mode neural Start a local node with a vector arm. The all-MiniLM-L6-v2 model downloads once, about 90 MB.
RUN THIS XERJ COMMAND xerj autoindex ./docs --url http://127.0.0.1:9200 --progress plain Index a folder. Full-text and vector fields go into the same index.
RUN THIS XERJ COMMAND curl -s -XPOST 'http://127.0.0.1:9200/docs/_search' -H 'content-type: application/json' -d '{"query":{"hybrid":{"queries":[{"query":{"match":{"body":"server unreachable"}},"weight":1.0},{"query":{"knn":{"field":"body_vector","k":10,"num_candidates":50,"query_vector":[]}},"weight":1.0}],"fusion":{"type":"rrf","k":60}}},"size":5}' One hybrid request. Fill query_vector with your embedding; the empty array marks where the floats go.

BM25, vector or hybrid: pick for your queries

Try it: 4 questions

BM25, vector or hybrid search for your RAG queries?

1. What do your users type?
2. What is in the corpus?
3. Can you run an embedding model?
4. What matters most?

Pick an answer above.

Full text · default XERJ mode

BM25 only

Exact terms, offline, no model. nDCG@10 0.6572 on SciFact and 0.3016 on NFCorpus.

Embeddings · MiniLM

Vector only

Ranks by meaning. nDCG@10 0.6764 on SciFact and 0.3291 on NFCorpus.

BM25 + vectors · RRF k 60

Hybrid search

Both lists fused into one. Highest measured: nDCG@10 0.6993 on SciFact and 0.3448 on NFCorpus.

Runs in your browser and sends nothing. Each answer adds a point to the method it matches. The nDCG@10 scores are the XERJ BEIR runs published below.

How hybrid search works

Try it: step through one hybrid query

What happens to the question "server unreachable"

  1. 1. One question, two arms

    The same text goes to a BM25 full-text query and to a vector query over embeddings. Both run in the same index.

  2. 2. BM25 list

    BM25 ranks passages that hold the words "server" and "unreachable", with rare words worth more. A log line with the exact error string ranks high.

  3. 3. Vector list

    The vector arm ranks passages close in meaning, so a page that says "connection refused" can rank even with no shared word.

  4. 4. Fusion

    Reciprocal rank fusion adds 1 / (60 + rank) from each list. Passages near the top of both lists rise; a passage only one arm found still stays in.

  5. 5. Answer

    The fused top results go to the person, the RAG prompt or the AI agent, each with its file path so the answer can cite it.

Runs in your browser and sends nothing. A walk-through of the request shape, not a benchmark; measured numbers are in the dataset table on this page.

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, such as a function name, a product code or an error string. A passage that says the same thing in other words gets no score from it.

A vector query turns the question and each passage into embeddings and ranks by closeness of meaning, so "server unreachable" can reach "connection refused". It is weaker on exact tokens, where two similar identifiers sit close together in the vector space.

Hybrid search runs both and fuses the ranks. Reciprocal rank fusion adds 1 / (k + rank) for every list a passage appears in, with k = 60 in the original paper. It uses positions, not raw scores, so a BM25 score and a cosine similarity never have to share a scale. The page has a calculator you can try.

Hybrid search compared with BM25 and vector search

BM25 onlyVector onlyHybrid search
FindsExact words, names, IDs, error stringsParaphrases, loose questionsBoth, in one list
Can missThe same idea in other wordsOne-character differences, rare codesLess of either
NeedsAn inverted indexEmbeddings and a vector indexBoth, plus a fusion step
Good forLogs, code, product codesRecommendations, "more like this"RAG, AI agents, mixed queries
Try it: two lists, one ranking

How hybrid search puts lists together

BM25 listVector listFuse ranksOne result list

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.

The fusion method is reciprocal rank fusion, as described by Cormack, Clarke and Buettcher (SIGIR 2009). How XERJ turns this on is on the hybrid-search answer. This figure does not report a new score.

Measured: hybrid search on BEIR

XERJ ran BM25, vectors only, a reorder arm and hybrid RRF on two public BEIR datasets. Hybrid RRF ranked first on both. Switch datasets in the table.

Try it: switch datasets

BM25, vectors and hybrid on two public BEIR datasets

SciFact: 300 test queries over 5,183 documents

ArmnDCG@10Queries with no hits
BM250.65720
Vectors only (MiniLM)0.67640
BM25 top 30 reordered by MiniLM0.68550
Hybrid RRF0.69930
Runs in your browser and sends nothing. Measured by XERJ with --embed-mode neural and the built-in all-MiniLM-L6-v2 model; the default lexical embedder is not covered. Raw output is in benchmarks/beir-hybrid/results in the XERJ repository.

On SciFact, hybrid RRF scored nDCG@10 0.6993, against 0.6764 for vectors only and 0.6572 for BM25. On NFCorpus, it scored 0.3448, against 0.3291 and 0.3016. BM25 found no hits for 25 of the 323 NFCorpus queries, and the hybrid arm still returned results for every one of them. These runs used --embed-mode neural with the built-in all-MiniLM-L6-v2 model; the default XERJ embedder is lexical and runs offline. The full method is on hybrid search quality, measured with nDCG.

Hybrid search for RAG and AI agents

A RAG pipeline or an agent asks questions that mix exact terms and loose wording in the same sentence, for example "why does connect_timeout fail when the server is unreachable". BM25 locks onto the identifier, the vector arm onto the meaning, and the fused list gives the model both. A passage that only one arm found still reaches the prompt, so fewer answers start from the wrong context.

XERJ keeps the lexical index and the vectors in the same engine, so there is no separate vector database to run. Agents reach the same search through xerj mcp, and hits from xerj autoindex carry their file path for citations. A setup without a separate vector store is RAG without a vector database.

Run hybrid search on your own folder

  1. Install: curl -fsSL https://xerj.org/get | sh
  2. Start a local node with neural embeddings: xerj --embed-mode neural
  3. Index a folder: xerj autoindex ./docs --url http://127.0.0.1:9200 --progress plain
  4. Send one hybrid request with a match query, a knn query and "fusion":{"type":"rrf","k":60}. The full request is in the command list on this page.

Every command has a copy button. To hand the work to an agent, use Copy the prompt and paste it into Claude Code, Cursor or Codex. The step-by-step how-to is how to run hybrid search in XERJ, and how XERJ combines search explains the merge.

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). Those papers are research sources; the BEIR numbers above are XERJ measurements.

Related terms

Hybrid vs vector vs semantic search, BM25, semantic search, reciprocal rank fusion and reranking.

FAQ

What is hybrid search?

It runs a full-text search such as BM25 and a vector search on the same query, then merges the two ranked lists into one list, usually with reciprocal rank fusion.

Why use two searches instead of one?

The two methods find different things. Full-text search is strong on exact tokens such as names and error strings. A vector query is stronger on paraphrases. Hybrid search keeps both kinds of hits.

Is hybrid search better for RAG?

It is the safer default, because user questions mix exact terms and loose wording. On the two BEIR datasets XERJ measured, hybrid RRF scored the highest nDCG@10: 0.6993 on SciFact and 0.3448 on NFCorpus.

Do I need a vector database for hybrid search?

No. You need one place that holds an inverted index and vectors. XERJ keeps both in the same index and fuses them inside one request.

How does XERJ run hybrid search?

Start a node with neural embeddings, then send one hybrid request that holds a match query and a knn query, with fusion type rrf. The full request is in the command list on this page.

When is BM25 alone enough?

When users type exact names, IDs or error strings and you want to stay offline with no model. BM25 is the default XERJ mode. The picker on this page weighs your answers against BM25, vector and hybrid search.

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.

Evidence

Related