In collaboration with the Microsoft Semantic Kernel team, we are announcing the availability of hybrid search capabilities in the .NET Elasticsearch Semantic Kernel connector – the first vector database to implement this capability. Microsoft Semantic Kernel recently announced support of hybrid search use cases, which opened the door for customers to use Elasticsearch for a broader set of applications. Elasticsearch has supported hybrid search since version 8.8.0, and in this article we will walk through how to use hybrid search with Elasticsearch and Semantic Kernel.
You can find the latest version of the Elasticsearch Semantic Kernel connector with Hybrid Search support here. If you are not familiar with the Elasticsearch integration in Semantic Kernel for .NET, we suggest reading this article that we previously published.
What is Hybrid Search?
Hybrid Search is a powerful information retrieval strategy that combines two or more search techniques into a search algorithm. A typical use case is the combination of lexical search (i.e. BM25) combined with semantic search (i.e. kNN). By running these two strategies in parallel customers can get the most significant results, which feeds into better answer quality overall (Figure 1).

Figure 1: Hybrid search as the intersection between lexical and semantic search
In order to combine the results we can use different strategies. Each result in Elasticsearch produces a list of relevant documents, ordered by a score value. A score is a floating point number that represents the relevance of a document. Higher numbers mean better relevance.
If we have two lists of results, one coming from lexical and another from semantic how can we combine them?
One strategy is to use the Reciprocal Rank Fusion (RRF) algorithm. This algorithm rearranges the score of each document using the following algorithm:
score = 0.0
for q in queries:
if d in result(q):
score += 1.0 / (k + rank(result(q), d))
return score
Where:
- k is a ranking constant
- q is a query in the set of queries (e.g. lexical and semantic)
- d is a document in the result set of q
- result(q) is the result set of q
- rank(result(q), d) is the position (ranking) of document d in the results of query q
For instance, imagine we run a Hybrid Search query to get the top-3 significant documents. We use lexical and semantic queries and we set k=1.
The results for lexical query are (in order):
- Doc4
- Doc3
- Doc2
- Doc1
That means the most relevant document is Doc4 followed by Doc3, Doc2 and Doc1.
The results for semantic query are (in order):
- Doc3
- Doc2
- Doc1
- Doc5
We can then calculate the RRF scores using the previous algorithm. In the following table, we calculated the scores for the lexical and semantic results, and then summed the two values to obtain the final RRF score.
Documents | Lexical | Semantic | RRF |
---|---|---|---|
Doc1 | 1/(1+4) | 1/(1+3) | ⅕ + ¼ = 0.4500 |
Doc2 | 1/(1+3) | 1/(1+2) | ¼ + ⅓ = 0.5833 |
Doc3 | 1/(1+2) | 1/(1+1) | ⅓ + ½ = 0.8333 |
Doc4 | 1/(1+1) | 0 | ½ = 0.5 |
Doc5 | 0 | 1/(1+4) | ⅕ = 0.2 |
Sorting the RRF scores gives us the following results:
- Doc3
- Doc2
- Doc4
- Doc1
- Doc5
Finally, the top-3 results are: Doc3, Doc2 and Doc4.
The RRF algorithm is used by default with the hybrid search Elasticsearch integration for Semantic Kernel.
The Hybrid Search integration in Semantic Kernel
The latest version of the Elasticsearch Semantic Kernel connector implements the brand new IHybridSearch<TRecord>
interface in the ElasticsearchVectorStoreRecordCollection<TKey, TRecord>
type. This interface extends the existing functionality with a new method that looks like this:
HybridSearchAsync<TVector>(
TVector vector,
ICollection<string> keywords,
int top,
HybridSearchOptions<TRecord>? options = null,
[EnumeratorCancellation] CancellationToken cancellationToken = default)
Where:
- vector is the TVector for the semantic search (using kNN);
- keywords contain a collection of strings to be used in the lexical search terms query of Elasticsearch (the terms in the collection are treated as OR conditions);
- top indicates the maximum number of documents to return;
- options options like e.g. the vector property/field to use for the vector search operation, the property/field to use for the lexical search operation, or an additional pre-filter specified in .NET expression tree syntax;
- cancellationToken the CancellationToken used to cancel the asynchronous operation;
For instance, imagine we reuse the hotel dataset introduced in the previous article How to use Elasticsearch Vector Store Connector for Microsoft Semantic Kernel for AI Agent development.
We can execute an Hybrid Search query to retrieve the top-5 hotels containing the keywords “downtown” or “luxury” combined with a semantic search using the vector {1, 2, 3}:
var results = (collection as IKeywordHybridSearch<Hotel>)
.HybridSearchAsync(
new float[] { 1, 2, 3 },
["downtown", "luxury"],
5
).ToBlockingEnumerable().ToList();
If we want to apply a filter before executing the Hybrid Search, we can do that by using the HybridSearchOptions
. For instance, imagine we want to consider only the hotels that are beachfront, we can add a filter using the expression Filter = x => x.Description.Contains("beachfront")
as follows:
var results = (collection as IKeywordHybridSearch<Hotel>)
.HybridSearchAsync(
new float[] { 1, 2, 3 },
["downtown", "luxury"],
5,
new HybridSearchOptions<Hotel>
{
Filter = x => x.Description.Contains("beachfront")
}
).ToBlockingEnumerable().ToList();
In this way, the search will consider only the beachfront hotels and then apply the previous Hybrid Search criteria (hint: expression tree-based filtering is also available for the regular vector search in Semantic Kernel).
The support for expression tree-based filtering in recent versions of Semantic Kernel is a nice improvement over the previous filtering API. Right now, the Elasticsearch Semantic Kernel connector only supports comparison (=, !=, <, <=, >, >=) and boolean (!, &&, ||) operators. More operations like collection.Contains()
will be implemented soon.
Hybrid search for .NET apps, with Elasticsearch and Semantic Kernel
In this article, we showed how to use Semantic Kernel’s Hybrid Search features with Elasticsearch integration. We illustrated how to combine lexical and semantic search to improve the retrieval results. This technique can be used for improving information retrieval systems, such as Retrieval-augmented generation (RAG). Moreover, we also looked at applying pre-filtering using the HybridSearchOptions object. The filtering condition can be expressed using the .NET expression tree syntax.
While Reciprocal Rank Fusion provides a robust default for combining lexical and semantic scores in hybrid search—as we saw in this blog with Semantic Kernel, Elasticsearch also more broadly supports other retriever styles. This includes options like the Linear Retriever, providing simple customization of combination strategies beyond the RRF default, enabling users to fine-tune search relevance with hybrid approaches.
In the future, we will continue to expand support for Semantic Kernel with the latest features within Elasticsearch. Happy (hybrid) searching!
Ready to try this out on your own? Start a free trial.
Elasticsearch has integrations for tools from LangChain, Cohere and more. Join our advanced semantic search webinar to build your next GenAI app!
Related content

June 5, 2025
Making sense of unstructured documents: Using Reducto parsing with Elasticsearch
Demonstrating how Reducto's VLMs can be integrated with Elasticsearch for semantic search.

May 20, 2025
Spring AI and Elasticsearch as your vector database
Building a complete AI application using Spring AI and Elasticsearch.

May 21, 2025
Get set, build: Red Hat OpenShift AI applications powered by Elasticsearch vector database
The Elasticsearch vector database is now supported by the ‘AI Generation with LLM and RAG’ Validated Pattern. This blog walks you through how to get started.

May 8, 2025
Unstructured data processing with NVIDIA NeMo Retriever, Unstructured, and Elasticsearch
Learn how to build a scalable data pipeline for unstructured documents using NeMo Retriever, Unstructured Platform, and Elasticsearch for RAG applications.

April 21, 2025
Using LlamaIndex Workflows with Elasticsearch
Learn how to create an Elasticsearch-based step for your LlamaIndex workflow.