
Skill
documentdb-full-text-search
implement full-text search in Azure DocumentDB
Description
Full-text search best practices for Azure DocumentDB using the `createSearchIndexes` command and `$search` aggregation stage — BM25 keyword scoring, fuzzy search (`maxEdits`), phrase search with `slop`, custom analyzers (keyword + lowerCase + asciiFolding + edgeGram) for prefix / ID matching, `pathHierarchy` tokenizer for hierarchical IDs, multi-field search indexes, and hybrid (BM25 + vector) retrieval via Reciprocal Rank Fusion. Use when building search experiences, adding typo tolerance, matching phrases or prefixes on IDs / SKUs / part numbers, or combining lexical and semantic retrieval on the same collection.
SKILL.md
Full-Text Search — Azure DocumentDB ($search + createSearchIndexes)
Azure DocumentDB's full-text search is driven by search indexes built with the createSearchIndexes database command and queried through the $search aggregation stage. Scoring is BM25, exposed via $meta: "searchScore". The community $text operator and { field: "text" } index type are not the DocumentDB search path.
Key syntax points that differ from many blog posts and older docs:
- Index command is
createSearchIndexes(notcreateIndexes) — each index has anameand adefinition.mappings.fieldsblock;dynamic: falseis the safe default. - Custom analyzers live inside
definition.analyzersand are referenced per-field viaanalyzer/searchAnalyzer. $searchtargets an index by name viaindex: "<name>"— the engine does not auto-pick when multiple exist.- No
countfield inside$search— use a downstream{ $limit: N }stage. - No
compoundoperator yet — query one field at a time and merge in the application (seefts-multifield-index).
Rules
- fts-create-search-index — Create a search index via
runCommand({ createSearchIndexes }); usedefinition.mappingswithdynamic: false. - fts-basic-search —
$search+textoperator for BM25 keyword search; targetindex, projectsearchScore, cap with$limit. - fts-fuzzy-search — Add
fuzzy: { maxEdits: 1 }to tolerate typos; keepmaxEditssmall. - fts-phrase-search —
phraseoperator withslopfor ordered-proximity matching. - fts-custom-analyzers — Keyword tokenizer +
lowerCase+asciiFolding+edgeGramfor case-insensitive prefix matching on IDs, SKUs, part numbers. Index-time vs search-time analyzer pair. - fts-path-hierarchy —
pathHierarchytokenizer for hierarchical identifiers (BN-747-ENG-2024.05, dotted, slash paths). - fts-multifield-index — One search index mapping multiple fields; fan-out-and-merge in the app while
$searchcompoundis unavailable. - fts-hybrid-search — Combine BM25 and vector search (RRF) on the same collection.
More skills from the documentdb-agent-kit repository
View all 17 skillsdocumentdb-azure-deployment
deploy Azure DocumentDB clusters
Jul 12AzureBicepCLIDatabase +2documentdb-connection
configure MongoDB connections for DocumentDB
Jul 12AzureDatabasePerformancedocumentdb-data-modeling
design Azure DocumentDB data models
Jul 12AzureData ModelingDatabaseMongoDBdocumentdb-driver
implement Azure DocumentDB driver best practices
Jul 12AzureDatabaseMongoDBSDKdocumentdb-high-availability
configure high availability for DocumentDB
Jul 12AzureDatabaseOperationsPerformancedocumentdb-indexing
select and shape Azure DocumentDB indexes
Jul 12AzureCosmos DBDatabaseNoSQL
More from Azure (Microsoft)
View publisherazure-arg-external-evaluation-policy-author
author and test Azure Resource Graph policies
azure-policy
Jul 12AzureComplianceGovernancePolicyazure-blueprints-migration
migrate Azure Blueprints to Template Specs
azure-blueprints
Jul 12AzureDeploymentInfrastructure as CodeMigrationapiview-feedback-resolution
resolve APIView feedback on Azure SDKs
azure-sdk-tools
Jul 12API DevelopmentAzureCode ReviewDocumentationazsdk-common-live-and-recorded-tests
deploy resources and run Azure SDK tests
azure-sdk-tools
Jul 12AzureDeploymentSDKTestingazsdk-common-prepare-release-plan
manage Azure SDK release plan work items
azure-sdk-tools
Jul 12AzureGitHubProject ManagementSDKazsdk-common-sdk-release
release Azure SDK packages
azure-sdk-tools
Jul 12AzureCI/CDDeploymentSDK