RAG & Retrieval

Advanced Search Capabilities in Dataworkz: Hybrid Search

Combining keyword and semantic search, with reciprocal rank fusion, to retrieve what either method alone would miss.

Key takeaways

  • Retrieval quality is key to RAG success. Two core techniques exist: lexical/sparse search (BM25/TF-IDF keyword matching, a surprisingly strong baseline) and vector/dense semantic search (embeddings with cosine similarity that capture intent rather than exact terms).
  • Each approach has weaknesses — lexical search requires users to use the same terms found in documents, while semantic search is affected by document length and domain specificity — and research has shown that combining them via Hybrid Search improves retrieval more than either approach alone.
  • Dataworkz RAG Builder offers three retrieval mechanisms selectable with a single choice: Lexical Pre-filter (lexical first, then semantic re-ranking), Semantic Only (vector search only), and Hybrid Search (independent lexical and semantic search, then merging and re-ranking).
  • At ingestion, data is stored in both a sparse index (e.g., ElasticSearch, MongoDB, RedisSearch) and a dense embedding store (e.g., MongoDB, Pinecone, with embeddings via mpnet, nomic, etc.); at retrieval, lexical search applies stop-word removal and stemming while semantic search applies a similarity algorithm, each returning documents sorted by score.
  • Dataworkz combines results using Reciprocal Rank Fusion (RRF), which re-ranks based on a document's presence and relative ranking across multiple result sets and needs no score normalization or user setup — chosen over weighted sum of scores because, although weighting can outperform RRF with the right parameters, tuning those weights (sometimes per dataset) is complex enough to negate the advantage.
On this pagesections

    Key to the success of RAG systems is the quality (relevance) of the information retrieved. Traditionally, search systems have relied on keyword/phrase matching with BM25 (usually) being the mechanism to provide a relevance score to the search results. Research has indicated that BM25 provides a surprisingly good baseline to beat in benchmarks for retrieval systems. This mechanism of information retrieval is also called lexical or sparse model retrieval.

    A typical drawback of phrase/keyword matching is that terms in the query have to be present in the document. While certain leeway can be provided by techniques such as stemming, it is still a keyword matching mechanism that does not take into account the semantic content or intent of the users’ queries. Semantic Retrieval using vector embeddings using, say, cosine similarity is a mechanism where we can encode the data in our corpus in N dimensions and identify documents that are the closest in terms of intent/concept to the user query which overcomes some of these limitations.

    So we now have a couple of techniques on how to perform information retrieval –

    • Lexical or Sparse Model search – leveraging BM25/TF-IDF mechanisms to perform keyword matching of user queries with documents
    • Vector or Dense Model search – leveraging vector similarity on vector embeddings of data and the question to identify the most similar documents

    Apart from using these mechanisms individually, we can also explore a few advanced mechanisms on how to put these two together

    • Lexical pre-filter – Being able to apply lexical search and then rerank the lexical search results using a similarity search can help improve the relevance of the documents based on the user query
    • Hybrid Search – here we leverage both search mechanisms individually taking advantage of their inherent strengths and then use a re-ranking algorithm to bring the results together

    Both systems can suffer from drawbacks individually – Lexical search systems require that the user have used the same terms/jargon as what is found in relevant documents. They can also result in poorer searches because of the influence of the part of the query that is meant for the LLM versus information retrieval. Semantic search is influenced by the length of the document, domain specificity and other considerations. Research has shown that Hybrid search can improve the results of information retrieval more than any one approach. The idea being that a document that shows up in both search results is likely to be relevant depending on its relative ranking compared to other results thereby promoting relevant results and suppressing less relevant results.

    Let’s take a look at how Hybrid search can be incorporated into Dataworkz.

    Hybrid Search in Dataworkz

    Dataworkz RAG Builder strives to make advanced RAG mechanisms easy to use by RAG Designers. Towards this, Dataworkz RAG Builder provides the following retrieval mechanisms –

    • Lexical Pre-filter (Lexical first followed by Semantic based re-ranking)
    • Semantic Only (only vector search is performed)
    • Hybrid Search (Independent Lexical and Semantic Search followed by merging and re-ranking)

    RAG Designers can take advantage of the powerful retrieval mechanism provided by Hybrid Search by just making a single selection of the retrieval mechanism to use.

    How does Hybrid Search work in Dataworkz?

    When data is ingested, data is stored in multiple indices –

    • A sparse encoding such as a lexical search system (such as ElasticSearch, MongoDB, RedisSearch, etc)
    • A dense encoding such as a embeddings (created vai mpnet, nomic, etc) and stored in a vector storage system (such as MongoDB, Pinecone, etc)

    During retrieval, Dataworkz RAG Engine takes the users’ search query and performs multiple retrieval searches on different stores

    • lexical search retrieval applies stop words removal and stemming and collect a list of relevant documents sorted by score
    • Semantic search retrieval applies the similarity algorithm (e.g. cosine) to identify most similar documents sorted by score

    Relevant documents returned by multiple retrieval systems have to be combined using some mechanism. A couple of approaches to this are –

    • Reciprocal Rank Fusion (RRF) – a simple but effective mechanism that re-ranks search results taking into account their presence in multiple search results and their relative ranking. It has the advantage of not needing score normalization between different systems.
    • Weighted sum of scores – a powerful mechanism that can combine results based on weights of scores from different systems

    Dataworkz RAG engine performs RRF on document results and creates a combined retrieval mechanism. Weighted sum of scores can provide better results than RRF when the correct weights and other parameters are set up. However, the complexity of getting the right weights (sometimes per dataset) and parameters right can be challenging for users and negate the advantages over RRF. RRF is quite resilient and requires no setup from the user which significantly improves the success rate of Hybrid search using RRF.

    Conclusion

    Hybrid search is a powerful technique that combines the advantages of sparse (lexical) and dense (semantic) search mechanisms. Dataworkz RAG makes leveraging Hybrid search easy by pulling togehter all the search queries and combining them with the industry standard RRF algorithm. Context retrieval is the key to a successful RAG implementation and user experience. Hybrid search allows for a wider range of user queries to return successful responses. Hybrid Search capabilities are aligned with Dataworkz’ philosophy of helping RAG Designers be successful in their implementations by easily incorporating the latest advancements and best practices as well as making advanced techniques as easy to use as a click of a button. Dataworkz RAG will continue to look at improvements in this space to incorporate new research (publicly or our own), techniques and best practices to make Hybrid search results more relevant.

    Frequently asked questions

    What is hybrid search in RAG?

    Hybrid search runs lexical (sparse/keyword) and semantic (dense/vector) retrieval independently, taking advantage of each one's strengths, then merges and re-ranks the results so documents appearing across both sets are promoted and less relevant ones are suppressed.

    How does lexical search differ from semantic search?

    Lexical (sparse) search uses keyword matching via mechanisms like BM25/TF-IDF and requires query terms to appear in the documents. Semantic (dense) search encodes data and queries as vector embeddings and uses similarity (e.g., cosine) to find documents closest in intent or concept, overcoming the exact-term limitation.

    What is Reciprocal Rank Fusion (RRF) and why does Dataworkz use it?

    RRF is a simple, effective method that re-ranks search results based on their presence and relative ranking across multiple result sets. Dataworkz uses it because it needs no score normalization between systems and no user setup, making it resilient and improving the success rate of hybrid search — whereas weighted sum of scores can require complex, sometimes per-dataset tuning.

    How do I enable hybrid search in Dataworkz?

    RAG Designers select the desired retrieval mechanism — Lexical Pre-filter, Semantic Only, or Hybrid Search — with a single selection in Dataworkz RAG Builder.

    See what your engineers can ship in production

    Dataworkz is the agentic AI platform enterprises trust to put AI agents into production. Teams build production-ready agents in days, every decision stays traceable, and every agent has ROI attached.

    Explore the platform