{"id":4467,"date":"2025-04-09T12:48:37","date_gmt":"2025-04-09T19:48:37","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/semantic-kernel\/?p=4467"},"modified":"2025-04-10T12:08:04","modified_gmt":"2025-04-10T19:08:04","slug":"announcing-hybrid-search-with-semantic-kernel-for-net","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/agent-framework\/announcing-hybrid-search-with-semantic-kernel-for-net\/","title":{"rendered":"Announcing Hybrid Search with Semantic Kernel for .NET"},"content":{"rendered":"<p>Today we\u2019re thrilled to announce support for Hybrid search with Semantic Kernel Vector Stores for .NET.<\/p>\n<h2><strong>What is Hybrid Search?<\/strong><\/h2>\n<p>Hybrid search performs two parallel searches on a vector database.\u00a0 The union of the results of these two searches are then returned to callers with a combined rank, based on the rankings from each of the constituent searches.\u00a0 The two searches typically consist of 1. a vector similarity search and 2. a keyword search over the source text of the vector from search 1.<\/p>\n<p>Using hybrid search typically results in much better RAG performance than just using regular vector similarity search.<\/p>\n<h2><strong>Using Hybrid Search:<\/strong><\/h2>\n<p>To use Hybrid Search with the Semantic Kernel Vector Stores, your schema will require two properties:<\/p>\n<ol>\n<li>The vector field that the vector similarity search would target<\/li>\n<li>The text field that the keyword search would target<\/li>\n<\/ol>\n<p>Typically, the vector field and the text field are interrelated.\u00a0 The embedding that was generated from the text is stored in the vector field.<\/p>\n<p>Here is an example data model class with annotations to mark the DescriptionEmbedding field as our Vector and the Description field as our text field.\u00a0 Note that the text field is marked as FullTextSearchable.\u00a0 This is required to index the Description field for keyword search when creating the collection.<\/p>\n<pre class=\"prettyprint language-default\"><code class=\"language-default\">public sealed class Product\r\n\r\n{\r\n\u00a0 \u00a0 [VectorStoreRecordKey]\r\n\u00a0 \u00a0 public int Key { get; set; }\r\n\r\n\r\n\u00a0 \u00a0 [VectorStoreRecordData(IsFullTextSearchable = true)]\r\n\u00a0 \u00a0 public string Description { get; set; }\r\n\r\n\r\n\u00a0 \u00a0 [VectorStoreRecordVector(1536)]\r\n\u00a0 \u00a0 public ReadOnlyMemory&lt;float&gt; DescriptionEmbedding { get; set; }\r\n}<\/code><\/pre>\n<div>Not all databases support hybrid search using keyword search, so only the connectors for databases that support this feature, implement the interface required for hybrid search.\u00a0 Make sure therefore to cast your collection to IKeywordHybridSearch&lt;TRecord&gt; before searching.<\/div>\n<div><\/div>\n<div>\n<pre class=\"prettyprint language-default\"><code class=\"language-default\">var hybridSearchCollection = (IKeywordHybridSearch&lt;Product&gt;)vectorStore.GetCollection&lt;int, Product&gt;(\"skproducts\");\r\nvar searchResult = await hybridSearchCollection.HybridSearchAsync(searchVector, [\"powertool\", \"sander\", \"electric\"]);<\/code><\/pre>\n<\/div>\n<h2>Documentation &amp; Samples<\/h2>\n<p>Check out the following page for more detailed documentation on how to use Hybrid Search: <a href=\"https:\/\/learn.microsoft.com\/semantic-kernel\/concepts\/vector-store-connectors\/hybrid-search\">https:\/\/learn.microsoft.com\/semantic-kernel\/concepts\/vector-store-connectors\/hybrid-search<\/a><\/p>\n<p>We also have an end to end sample using Azure AI Search with Hybrid Search here: <a href=\"https:\/\/github.com\/microsoft\/semantic-kernel\/blob\/main\/dotnet\/samples\/Concepts\/Memory\/VectorStore_HybridSearch_Simple_AzureAISearch.cs\">https:\/\/github.com\/microsoft\/semantic-kernel\/blob\/main\/dotnet\/samples\/Concepts\/Memory\/VectorStore_HybridSearch_Simple_AzureAISearch.cs<\/a><\/p>\n<p>For information on which connectors currently support Hybrid Search, please consult the page for each connector: <a href=\"https:\/\/learn.microsoft.com\/semantic-kernel\/concepts\/vector-store-connectors\/out-of-the-box-connectors\">https:\/\/learn.microsoft.com\/semantic-kernel\/concepts\/vector-store-connectors\/out-of-the-box-connectors<\/a><\/p>\n<h2>Coming Soon<\/h2>\n<p>Watch this space for announcements around support for hybrid search for Python.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Today we\u2019re thrilled to announce support for Hybrid search with Semantic Kernel Vector Stores for .NET. What is Hybrid Search? Hybrid search performs two parallel searches on a vector database.\u00a0 The union of the results of these two searches are then returned to callers with a combined rank, based on the rankings from each of [&hellip;]<\/p>\n","protected":false},"author":162052,"featured_media":2364,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[78,1],"tags":[79,48,82,63,9],"class_list":["post-4467","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-net","category-semantic-kernel","tag-net","tag-ai","tag-announcement","tag-microsoft-semantic-kernel","tag-semantic-kernel"],"acf":[],"blog_post_summary":"<p>Today we\u2019re thrilled to announce support for Hybrid search with Semantic Kernel Vector Stores for .NET. What is Hybrid Search? Hybrid search performs two parallel searches on a vector database.\u00a0 The union of the results of these two searches are then returned to callers with a combined rank, based on the rankings from each of [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/agent-framework\/wp-json\/wp\/v2\/posts\/4467","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/agent-framework\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/agent-framework\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/agent-framework\/wp-json\/wp\/v2\/users\/162052"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/agent-framework\/wp-json\/wp\/v2\/comments?post=4467"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/agent-framework\/wp-json\/wp\/v2\/posts\/4467\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/agent-framework\/wp-json\/wp\/v2\/media\/2364"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/agent-framework\/wp-json\/wp\/v2\/media?parent=4467"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/agent-framework\/wp-json\/wp\/v2\/categories?post=4467"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/agent-framework\/wp-json\/wp\/v2\/tags?post=4467"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}