What is hybrid search?

Hybrid search definition

Hybrid search is a powerful information retrieval strategy that combines two or more search techniques into a search algorithm.

Typically, hybrid search combines keyword search and semantic search, utilizing advanced machine learning techniques. Semantic search retrieves results based on the meaning of the text, while full-text search focuses on exact word matches. Hybrid search is vital for conversational queries and those 'what was that called again?' moments where users don't or can't enter precise keywords.

Both keyword search and semantic search have unique strengths. Keyword search uses a ranking algorithm and specific terms to determine how relevant a document is to a search query. Semantic search takes the search query and considers the context.

Hybrid search improves search precision by combining the strengths of semantic search and traditional search. Balancing semantic understanding and honoring exact query terms, hybrid search delivers results that improve the user search experience.

How hybrid search works

Hybrid search blends keyword and vector search to deliver comprehensive search results. Vector embeddings convert data, like sentences or photos, into numbers that capture their meaning and relationships. The data is tokenized, indexed, and represented by numerical embeddings. Vector search can capture meaning in unstructured data. Vector search overcomes limitations in keyword search — allowing users to search by what they mean, even if they can't recall a precise description or exact keyword. Hybrid search can parse both dense and sparse vectors for the most relevant results.

Dense vectors

Dense vectors handle semantic understanding and contextual queries. They are commonly used in modern machine learning, especially for tasks like generating embeddings.

Sparse vectors

Sparse vectors handle traditional keyword-based indexing and are sparsely populated with information. These vectors are commonly used for large data sets.

Query processing

Query processing in hybrid search uses sparse vectors for exact keyword matching and prioritization and dense vectors for semantic understanding, capturing contextual meaning and intent. By combining these two types of vectors, hybrid search delivers comprehensive search results that balance specificity and relevance. To achieve results, hybrid search uses reciprocal rank fusion (RRF) to combine multiple result sets (each with different relevance indicators) into a single result set.

Hybrid search with RAG

Retrieval augmented generation (RAG) is a search technique that uses private or proprietary data sources to provide context that supplements your LLM's original knowledge base. RAG is valuable for queries because it enables generative AI systems to use external information sources to produce more relevant responses.

Using hybrid search with RAG — and bringing in additional sources of data — can improve the relevance of a search experience by adding context. Additional information sources can be anything that organizations or customers might need to answer a query, from new information on the internet to proprietary or confidential business documents.

RAG offers several benefits over language models that work in isolation. It’s cost-effective, requires less computing and storage, and ensures your model can access the most up-to-date information.

RAG in action

Hybrid search with Elastic

Elastic makes it easy to implement hybrid search by supporting semantic search out-of-the-box. With Elastic, hybrid search can be performed on one platform, one API, and a speed and scale with better relevance from the onset.

Using Elastic's playground, developers can explore grounding LLMs of their choice with their own private data in a low-code interface.

Elastic helps developers simplify query construction with newly introduced query retrievers — standard, kNN, and RRF. Using these queries, Elastic understands the selected data and will automatically generate a unified query.