Hybrid search

Hybrid search combines keyword search and vector-based semantic search in one query and merges their results, so a system finds both exact terms and passages that match the meaning.

Search systems have two main ways of finding text. Keyword or lexical search, usually scored with an algorithm called BM25, rewards documents that contain the exact words in the query. It is excellent for names, product codes and error messages, but misses a document that says the same thing in different words. Semantic search compares embeddings, numerical representations of meaning, so it finds relevant passages with no words in common, but it can miss an exact identifier. Hybrid search runs both and merges the results into one ranked list.

The merging step is called fusion. Reciprocal rank fusion ignores the raw scores and uses only each document's position: a document earns 1 divided by the sum of a constant and its rank in each list, and those amounts are added up. Elasticsearch sets the constant to 60 by default, following a 2009 paper by Cormack and colleagues. Linear combination instead normalises the two sets of scores and blends them with weights, which gives finer control but needs tuning. Weaviate exposes this as a single setting, alpha, where 1 means pure vector search and 0 pure keyword search.

Two examples show why both halves matter. Elastic cites a shopping query like comfortable dress shoes for the office, which mixes precise product terms with descriptive intent. Anthropic cites a support query about a specific error code, TS-999: an embedding search may return general material about error codes, while keyword search finds the exact one.

Hybrid search is now common in retrieval-augmented generation. In Anthropic's September 2024 tests of its contextual retrieval method, adding keyword search to embedding search cut the share of queries that missed the right passage in the top 20 results from 3.7% to 2.9%. Many systems add a reranking model after fusion to sort the merged list more carefully.

In practice, most search engines and vector databases now offer hybrid search as a built-in option. The costs are keeping two indexes up to date and choosing how to weight them, which is best done by testing with real queries.

Common questions

What is hybrid search?

It is a search method that runs keyword search and semantic vector search together and combines their results. Keyword search catches exact terms; semantic search catches meaning. The combination usually returns better results than either alone, especially for mixed queries.

Why not just use vector search?

Vector search is good at meaning but can miss exact strings such as part numbers, names, legal citations or error codes. Keyword search handles those reliably. Combining the two covers each method's blind spots, which matters a great deal in retrieval for AI assistants.

What is reciprocal rank fusion?

It is a simple way to merge ranked lists from different search methods. Each document scores 1 divided by a constant plus its rank in each list, and the scores are summed. Because it uses only positions, it needs no tuning of the underlying scores, which makes it a popular default.

What does the alpha parameter mean in hybrid search?

In systems such as Weaviate, alpha sets the balance between vector and keyword results. An alpha of 1 is pure vector search and 0 is pure keyword search, with values in between blending the two. The best value depends on your data and is found by testing.

Finding more

Search for "hybrid search BM25 vector", "reciprocal rank fusion" or "hybrid retrieval RAG" to see how fusion is configured and evaluated. Documentation from search engines and vector databases explains the available settings, and information retrieval research and published retrieval benchmarks show how much each method helps. Be cautious with vendor claims of large gains that do not state the dataset used.

  • What is hybrid search?ArticleElastic's explainer on combining lexical and semantic search, with fusion methods and examples.
  • Reciprocal rank fusionOfficialElasticsearch documentation giving the RRF formula and its default constant of 60.
  • Hybrid searchOfficialWeaviate's documentation on the alpha setting and its fusion methods.
  • Introducing Contextual RetrievalArticleAnthropic's 2024 retrieval experiments combining embeddings with BM25 keyword search.

Working out what this means for your business?

Aileron Shift builds the systems behind this site: AI newsrooms that research, write and publish on their own, marketing automation and WordPress hosting for companies that need to move faster than their competitors.