{"id":259,"date":"2026-11-17T10:45:10","date_gmt":"2026-11-17T18:45:10","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/documentdb\/?p=259"},"modified":"2026-11-16T12:42:24","modified_gmt":"2026-11-16T20:42:24","slug":"fts-azure-documentdb","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/documentdb\/fts-azure-documentdb\/","title":{"rendered":"Go beyond exact matches with full-text search in Azure DocumentDB"},"content":{"rendered":"<p>A customer searches for &#8220;waterprof jacket.&#8221; They expect your application to understand the typo, find relevant products, and show options they can buy. Someone searching a knowledge base for &#8220;connection timeout&#8221; needs a different kind of precision: those words should appear together, not somewhere in an unrelated article.<\/p>\n<p>Azure DocumentDB full-text search, currently in preview, helps you build both experiences without adding and syncing a separate search service, such as Elasticsearch or OpenSearch. Combine relevance-ranked keyword search, typo tolerance, phrase and proximity matching, custom analyzers, and structured conditions through MongoDB-compatible commands and aggregation pipelines.<\/p>\n<p>When your application also needs semantic retrieval, combine full-text and vector search against the same collection.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/documentdb\/wp-content\/uploads\/sites\/93\/2026\/11\/Azure-DocumentDB_-Beyond-Exact-Matches.webp\"><img decoding=\"async\" class=\"size-full wp-image-262 aligncenter\" src=\"https:\/\/devblogs.microsoft.com\/documentdb\/wp-content\/uploads\/sites\/93\/2026\/11\/Azure-DocumentDB_-Beyond-Exact-Matches.webp\" alt=\"Azure DocumentDB Beyond Exact Matches image\" width=\"1672\" height=\"941\" srcset=\"https:\/\/devblogs.microsoft.com\/documentdb\/wp-content\/uploads\/sites\/93\/2026\/11\/Azure-DocumentDB_-Beyond-Exact-Matches.webp 1672w, https:\/\/devblogs.microsoft.com\/documentdb\/wp-content\/uploads\/sites\/93\/2026\/11\/Azure-DocumentDB_-Beyond-Exact-Matches-300x169.webp 300w, https:\/\/devblogs.microsoft.com\/documentdb\/wp-content\/uploads\/sites\/93\/2026\/11\/Azure-DocumentDB_-Beyond-Exact-Matches-1024x576.webp 1024w, https:\/\/devblogs.microsoft.com\/documentdb\/wp-content\/uploads\/sites\/93\/2026\/11\/Azure-DocumentDB_-Beyond-Exact-Matches-768x432.webp 768w, https:\/\/devblogs.microsoft.com\/documentdb\/wp-content\/uploads\/sites\/93\/2026\/11\/Azure-DocumentDB_-Beyond-Exact-Matches-1536x864.webp 1536w\" sizes=\"(max-width: 1672px) 100vw, 1672px\" \/><\/a><\/p>\n<h2>Rank keyword matches by relevance<\/h2>\n<p>Finding a matching document is only the first step. Your application also needs to decide which results to show first.<\/p>\n<p>Azure DocumentDB uses BM25 to rank text matches. BM25 considers how often query terms appear, how common those terms are across the collection, and document length. Your application can read each result&#8217;s score through <code>searchScore<\/code>.<\/p>\n<p>Search a single field or query multiple mapped fields, such as a product&#8217;s title and description. Set <code>matchCriteria<\/code> to <code>\"all\"<\/code> when every analyzed query term must match, or <code>\"any\"<\/code> when one matching term is enough.<\/p>\n<p>Learn more about <a href=\"https:\/\/learn.microsoft.com\/azure\/documentdb\/full-text-search-keyword\">BM25 keyword search<\/a>.<\/p>\n<h2>Handle typos with fuzzy search<\/h2>\n<p>A misspelled word shouldn&#8217;t send customers to an empty results page.<\/p>\n<p>Fuzzy search lets a text query match terms within a specified edit distance. For example, &#8220;waterprof&#8221; can match &#8220;waterproof&#8221; with <code>fuzzy: { maxEdits: 1 }<\/code>.<\/p>\n<p>Choose one or two character edits, depending on how much tolerance your application needs. Start with one edit for stricter matching. Broader tolerance can help with longer words, but it can also introduce unrelated results, especially for short inputs.<\/p>\n<p>Use fuzzy search for customer search boxes, knowledge bases, and other workloads where people enter imperfect text.<\/p>\n<p>Learn more about <a href=\"https:\/\/learn.microsoft.com\/azure\/documentdb\/full-text-search-fuzzy\">fuzzy search<\/a>.<\/p>\n<h2>Preserve word order with phrase and proximity matching<\/h2>\n<p>Sometimes the relationship between words matters as much as the words themselves.<\/p>\n<p>Phrase search lets you require query terms in order. With <code>slop: 0<\/code>, a query for &#8220;waterproof jacket&#8221; requires adjacent terms. With <code>slop: 1<\/code>, it can also match &#8220;waterproof hiking jacket&#8221;.<\/p>\n<p>Use proximity matching when titles or descriptions insert useful words between the terms your customer enters. Keep strict phrase matching for quoted searches, product names, or error messages where adjacency matters.<\/p>\n<p>The preview supports <code>slop<\/code> values from 0 through 10. The <code>phrase<\/code> operator doesn&#8217;t accept <code>fuzzy<\/code>. You can combine separate phrase and fuzzy-text clauses, but that combination doesn&#8217;t create typo-tolerant phrase matching.<\/p>\n<p>See the <a href=\"https:\/\/learn.microsoft.com\/azure\/documentdb\/full-text-search-phrase-proximity\">phrase and proximity guide<\/a>.<\/p>\n<h2>Combine search relevance with business requirements<\/h2>\n<p>A relevant product still needs to meet the customer&#8217;s requirements. Structured search lets you combine text matching with exact values, numeric or date ranges, field existence, and membership conditions.<\/p>\n<p>For example, find waterproof jackets while requiring available stock and a price below $100.<\/p>\n<p>First, enable the preview on your cluster. In the Azure portal, open <strong>Settings<\/strong> &gt; <strong>Features<\/strong> &gt; <strong>Full-text search<\/strong>, then select <strong>Enable<\/strong>. Wait 10 minutes before creating a search index or running queries.<\/p>\n<p>Connect through MongoDB Shell and create a new collection:<\/p>\n<pre><code class=\"language-javascript\">db.createCollection(\"searchBlogProducts\");\r\n\r\ndb.searchBlogProducts.insertMany([\r\n  {\r\n    _id: 1,\r\n    title: \"Waterproof hiking jacket\",\r\n    price: 79,\r\n    inStock: true\r\n  },\r\n  {\r\n    _id: 2,\r\n    title: \"Waterproof alpine jacket\",\r\n    price: 149,\r\n    inStock: true\r\n  },\r\n  {\r\n    _id: 3,\r\n    title: \"Waterproof trail jacket\",\r\n    price: 59,\r\n    inStock: false\r\n  }\r\n]);\r\n<\/code><\/pre>\n<p>Create a named search index with explicit mappings for the fields:<\/p>\n<pre><code class=\"language-javascript\">db.runCommand({\r\n  createSearchIndexes: \"searchBlogProducts\",\r\n  indexes: [\r\n    {\r\n      name: \"product_search\",\r\n      definition: {\r\n        mappings: {\r\n          dynamic: false,\r\n          fields: {\r\n            title: { type: \"string\" },\r\n            price: { type: \"number\", representation: \"double\" },\r\n            inStock: { type: \"boolean\" }\r\n          }\r\n        }\r\n      }\r\n    }\r\n  ]\r\n});\r\n<\/code><\/pre>\n<p>Check the index and wait until it reports <code>status: \"READY\"<\/code> and <code>queryable: true<\/code>:<\/p>\n<pre><code class=\"language-javascript\">db.searchBlogProducts.aggregate([\r\n  { $listSearchIndexes: { name: \"product_search\" } }\r\n]);\r\n<\/code><\/pre>\n<p>Now combine fuzzy text matching, a phrase preference, and purchase requirements:<\/p>\n<pre><code class=\"language-javascript\">db.searchBlogProducts.aggregate([\r\n  {\r\n    $search: {\r\n      index: \"product_search\",\r\n      compound: {\r\n        must: [\r\n          {\r\n            text: {\r\n              query: \"waterprof jacket\",\r\n              path: \"title\",\r\n              matchCriteria: \"all\",\r\n              fuzzy: { maxEdits: 1 }\r\n            }\r\n          }\r\n        ],\r\n        should: [\r\n          {\r\n            phrase: {\r\n              query: \"waterproof jacket\",\r\n              path: \"title\",\r\n              slop: 1\r\n            }\r\n          }\r\n        ],\r\n        filter: [\r\n          { equals: { path: \"inStock\", value: true } },\r\n          { range: { path: \"price\", lt: 100 } }\r\n        ]\r\n      }\r\n    }\r\n  },\r\n  { $limit: 10 },\r\n  {\r\n    $project: {\r\n      _id: 0,\r\n      title: 1,\r\n      price: 1,\r\n      score: { $meta: \"searchScore\" }\r\n    }\r\n  }\r\n]);\r\n<\/code><\/pre>\n<p>For this sample, the query returns the waterproof hiking jacket. Fuzzy matching accommodates the missing letter. The price condition excludes the alpine jacket, and the availability condition excludes the trail jacket.<\/p>\n<p>The <code>should<\/code> clause favors the phrase match but doesn&#8217;t require it. Move a phrase condition into <code>must<\/code> when every result must satisfy proximity requirements.<\/p>\n<p>Keep <code>$search<\/code> first in the pipeline. The preview can let <code>compound.filter<\/code> conditions affect relevance scores, so don&#8217;t assume those conditions leave scores unchanged.<\/p>\n<h2>Adapt text analysis to your data<\/h2>\n<p>Natural-language descriptions, SKUs, and catalog paths need different matching rules. Custom analyzers let you choose how Azure DocumentDB splits and normalizes text at index time and query time.<\/p>\n<p>Use an <code>edgeGram<\/code> analyzer to generate prefixes for identifiers. A customer entering <code>sku-shoe<\/code> can find <code>SKU-SHOE-001<\/code> without typing the complete value. Choose prefix lengths for your workload, since generating more prefixes increases index size.<\/p>\n<p>For hierarchical identifiers, use <code>pathHierarchy<\/code>. A path such as <code>catalog\/outdoor\/running<\/code> produces searchable hierarchy levels, allowing a query for <code>catalog\/outdoor<\/code> to match entries beneath that path.<\/p>\n<p>Analyzer pipelines also support case and accent normalization, stemming, stop-word removal, and pattern processing. Built-in analyzers handle Chinese, Japanese, Korean, and Thai.<\/p>\n<p>One index can cover multiple fields with different analysis rules. Named <code>multi<\/code> mappings also let you apply alternate analyzers to the same field without duplicating the source data.<\/p>\n<h2>Choose how results appear<\/h2>\n<p>Relevance isn&#8217;t always the only ordering your application needs.<\/p>\n<p>Use inline <code>$search.sort<\/code> to order results by mapped scalar fields, such as price or publication date. Keep the default relevance order when the best text match should appear first.<\/p>\n<p>Place <code>$limit<\/code> immediately after <code>$search<\/code> when possible so the engine can push top-N retrieval into search execution. If you need a downstream business filter, apply it before the final limit so your application doesn&#8217;t discard eligible results too early.<\/p>\n<h2>Combine keyword and vector search<\/h2>\n<p>Keywords help retrieve specific terminology. Vector search helps connect different wording with similar meaning.<\/p>\n<p>For a knowledge base, that combination can retrieve passages that contain a particular error name alongside passages that explain the same problem in different words.<\/p>\n<p>Azure DocumentDB supports full-text and vector indexes on the same collection. Your application supplies embeddings, runs both retrieval queries, and combines the ranked results through Reciprocal Rank Fusion. Implement fusion in application code or an aggregation pipeline.<\/p>\n<p>Follow the <a href=\"https:\/\/learn.microsoft.com\/azure\/documentdb\/full-text-search-hybrid\">hybrid search guide<\/a> for examples.<\/p>\n<h2>Get started with the preview<\/h2>\n<p>Azure DocumentDB includes full-text search with your cluster at no extra feature charge. Your cluster charges still apply.<\/p>\n<p>The preview requires explicit field mappings and doesn&#8217;t currently support synonyms, facets, highlighting, or the <code>autocomplete<\/code> operator. Custom analyzers provide prefix matching through text queries instead.<\/p>\n<p>Existing <code>$text<\/code> queries and text indexes keep their behavior. Create a separate search index to evaluate <code>$search<\/code> alongside your current application.<\/p>\n<p><div  class=\"d-flex justify-content-center\"><a class=\"cta_button_link btn-primary mb-24\" href=\"https:\/\/aka.ms\/FTSdocumentdb\" target=\"_blank\">Get started today!<\/a><\/div><\/p>\n<h2>About Azure DocumentDB<\/h2>\n<p>Azure DocumentDB is a fully managed document database service for building and modernizing MongoDB-compatible applications. Powered by the open-source DocumentDB engine, it combines familiar APIs, tools, and workflows with Azure&#8217;s security, scalability, and operational simplicity. Whether you&#8217;re developing new applications or migrating existing MongoDB workloads, Azure DocumentDB helps you get started quickly and scale with confidence.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>A customer searches for &#8220;waterprof jacket.&#8221; They expect your application to understand the typo, find relevant products, and show options they can buy. Someone searching a knowledge base for &#8220;connection timeout&#8221; needs a different kind of precision: those words should appear together, not somewhere in an unrelated article. Azure DocumentDB full-text search, currently in preview, [&hellip;]<\/p>\n","protected":false},"author":125132,"featured_media":262,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-259","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-azure-document-db"],"acf":[],"blog_post_summary":"<p>A customer searches for &#8220;waterprof jacket.&#8221; They expect your application to understand the typo, find relevant products, and show options they can buy. Someone searching a knowledge base for &#8220;connection timeout&#8221; needs a different kind of precision: those words should appear together, not somewhere in an unrelated article. Azure DocumentDB full-text search, currently in preview, [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/documentdb\/wp-json\/wp\/v2\/posts\/259","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/documentdb\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/documentdb\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/documentdb\/wp-json\/wp\/v2\/users\/125132"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/documentdb\/wp-json\/wp\/v2\/comments?post=259"}],"version-history":[{"count":1,"href":"https:\/\/devblogs.microsoft.com\/documentdb\/wp-json\/wp\/v2\/posts\/259\/revisions"}],"predecessor-version":[{"id":263,"href":"https:\/\/devblogs.microsoft.com\/documentdb\/wp-json\/wp\/v2\/posts\/259\/revisions\/263"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/documentdb\/wp-json\/wp\/v2\/media\/262"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/documentdb\/wp-json\/wp\/v2\/media?parent=259"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/documentdb\/wp-json\/wp\/v2\/categories?post=259"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/documentdb\/wp-json\/wp\/v2\/tags?post=259"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}