A keyword search index organizes searchable content so a query can retrieve relevant documents efficiently. In Atlas Search, the Lucene-powered index maps terms to document identifiers and records metadata such as term positions. Create the index before querying a collection with Atlas Search. section 11.3.3
Choose the index type for the search behavior you need. A traditional MongoDB text index supports keyword queries through $text, including relevance scores, but does not efficiently support partial-value searches such as regular expressions. Atlas Search is the recommended choice for fuller search capabilities; its indexes use additional disk space and memory. section 7.2.4 section 11.3.3
Configure an Atlas Search index around the fields users search, sort, or filter:
- Use static mappings to name the fields and their types. This is preferred for production because it avoids indexing unnecessary fields, saves disk space, and can improve performance. section 11.3.3
- Use dynamic mappings to index supported fields automatically when convenience matters, such as in a local test environment. Expect greater disk use and a possible performance impact. section 11.3.3 section 13.5.1
- Set analyzers for indexed strings when the default treatment of search terms does not fit the intended queries. section 11.3.3
Create and check a local index
In a local Atlas cluster, run `db.inspections.createSearchIndex("LocalSearchIndex", { mappings: { dynamic: true } })`. Then run `db.inspections.getSearchIndexes()` and check for `status: 'READY'` and `queryable: true`. A query can name `LocalSearchIndex` in the first `$search` aggregation stage; the inspections example searches `result` and `business_name`, allows two typographical edits, then filters and sorts by search score. section 13.5.1 section 11.8
For a cloud deployment, define a static mapping in a JSON file and create it with `atlas clusters search indexes create --clusterName <name> --file index-definition.json --output json`. Index builds are resource-intensive, so check status before querying. M0 clusters allow three Atlas Search indexes; M10 and higher have no index-count restriction stated here. Enabling Atlas Search adds no separate fee, but increased resource use can still matter. section 11.4
The index must also stay current as documents change: the `mongot` process manages Atlas Search indexes and applies updates from MongoDB change streams. This search workload is separate from core database operations. section 11.8 section 13.6


