Skip to main content
VePrompts

Hybrid Search for RAG: Combine Keyword and Vector Retrieval

Bottom line: Vector search understands meaning. Keyword search finds exact matches. Hybrid search gives you both, which is why it is now the default for production RAG systems.

The limits of pure vector search

Dense retrieval is great at capturing synonyms and concepts, but it can miss rare words, product codes, names, and abbreviations. If a user asks for "model XJ-900 firmware update," vector search may not understand that "XJ-900" is an exact identifier.

Keyword search with BM25

BM25 is a classic ranking function that scores documents by term frequency and inverse document frequency. It rewards rare terms and penalizes common words. Modern databases such as Elasticsearch, OpenSearch, and Meilisearch implement BM25 out of the box.

Reciprocal rank fusion

The challenge with hybrid search is that keyword scores and vector scores live on different scales. Reciprocal rank fusion solves this by using ranks instead of raw scores.

score(d) = sum(1 / (k + rank_d(method)))

A constant k, usually 60, prevents top ranks from dominating. You rank results from each method, compute the fusion score for every document, and sort by the total.

Tuning the alpha weight

Some systems use a weighted sum of sparse and dense scores instead of rank fusion. The alpha parameter sets the balance.

  • Alpha 0.3: favor keyword matching for catalogs, legal docs, and codebases with exact identifiers.
  • Alpha 0.7: favor vector matching for open-ended questions and conceptual queries.
  • Alpha 0.5: a safe starting point for general-purpose RAG.

Implementation checklist

  1. Index documents in both a vector store and a keyword-capable index.
  2. Run the same query through both indexes.
  3. Choose a fusion method: reciprocal rank fusion or weighted score sum.
  4. Normalize scores if you use the weighted sum approach.
  5. Evaluate recall and precision on your labeled test set while tuning alpha.

When hybrid search is not needed

If your corpus is large and your users ask conceptual questions, pure vector search may be simpler and faster. If every query contains IDs, names, or technical terms, keyword search may outperform vectors on its own. Test both before committing to hybrid complexity.

Published 2026-06-12

Related Resources

RAG Pipeline Architect

Prompt

Design production-ready Retrieval-Augmented Generation pipelines with advanced chunking strategies, embedding optimization, and hybrid search capabilities for enterprise knowledge bases.

RAG Implementation Expert

Skill

Build production-grade Retrieval-Augmented Generation systems with vector databases, embeddings, and hybrid search.

MODULAR RAG MCP SERVER

MCP Server

A modular RAG (Retrieval-Augmented Generation) system with MCP Server architecture. Using Skill to make AI follow each step of the spec and complete the code 100% by AI.

RAG

Glossary

RAG stands for Retrieval-Augmented Generation. It is a pattern that gives a language model access to information outside its training data by fetching relevant documents at query time and including them in the prompt. Instead of memorizing facts, the model reasons over retrieved snippets, which makes answers more accurate, current, and traceable. A typical RAG pipeline has four stages. First, documents are split into chunks and converted into embeddings using an embedding model. Second, those embeddings are stored in a vector database. Third, when a user asks a question, the system embeds the query and searches the database for the closest chunks. Finally, the retrieved chunks are added to the prompt as context, and the model generates an answer grounded in that evidence. RAG is especially useful when answers depend on private data, such as internal wikis, support tickets, or product documentation. It also reduces hallucination because the model can cite the retrieved text. Teams often tune RAG by changing chunk size, overlap, reranking algorithms, and query rewriting strategies.

Train an AI on Your Data

Prompt

Create a knowledge base and fine-tuning strategy for domain-specific AI responses.