Review Atlas Search Index Syntax
Atlas Search can index data in different ways. When you define an Atlas Search index,
you can specify a particular analyzer or multiple analyzers to index
certain fields. To learn more, see Process Data with Analyzers. You can also
index certain fields and omit others, or you can dynamically index all
the fields in a collection. To learn more, see
Define Field Mappings. You can define Atlas Search indexes through the
Atlas UI, Atlas Search API, Atlas CLI,
mongosh
, or Drivers.
This page describes the JSON syntax and fields for an Atlas Search index.
Important
Syntax
1 { 2 "mappings": { 3 "dynamic": <boolean>, 4 "fields": { <field-definition> } 5 } 6 } 7
1 { 2 "analyzer": "<analyzer-for-index>", 3 "searchAnalyzer": "<analyzer-for-query>", 4 "mappings": { 5 "dynamic": <boolean>, 6 "fields": { <field-definition> } 7 }, 8 "numPartitions": 4, 9 "analyzers": [ <custom-analyzer> ], 10 "storedSource": <boolean> | { 11 <stored-source-definition> 12 }, 13 "synonyms": [ 14 { 15 "name": "<synonym-mapping-name>", 16 "source": { 17 "collection": "<source-collection-name>" 18 }, 19 "analyzer": "<synonym-mapping-analyzer>" 20 } 21 ] 22 } 23
Options
Field | Type | Necessity | Description |
---|---|---|---|
| string | Optional | Specifies the analyzer to apply to string fields when indexing. If you set this only at the top and do not specify an analyzer for the fields in the index definition, Atlas Search applies this analyzer to all the fields. To use a different analyzer for each field, you must specify a different analyzer for the field. If omitted, defaults to Standard Analyzer. |
| array of Custom Analyzers | Optional | Specifies the Custom Analyzers to use in this index. |
| Required | Specifies how to index fields at different paths for this index. | |
| boolean | Optional | Enables or disables dynamic mapping of fields for this index. If set to If set to If omitted, defaults to IMPORTANT: Atlas Search dynamically indexes all fields in a For example index configurations, see Static Mapping Example or Combined Mapping Example |
| document | Conditional | Specifies the fields that you would like to index. Required only if dynamic mapping is disabled. You can't index fields that contain the dollar ( To learn more, see Define Field Mappings. |
| string | Optional | Specifies the analyzer to apply to query text before searching with it. If omitted, defaults to the
analyzer that you specify for the |
| int | Optional | Specifies the number of sub-indexes to create if the document count
exceeds two billion. The following values are valid: To use index partitions, you must have search nodes deployed in your cluster. ImportantThe |
| boolean or Stored Source Definition | Optional | Specifies fields in the documents to store for query-time look-ups using the returnedStoredSource option. You can store fields of all Data Types on Atlas Search. Value can be one of the following:
If omitted, defaults to To learn more, see Define Stored Source Fields in Your Atlas Search Index. |
| array of Synonym Mapping Definition | Optional | Synonym mappings to use in your index. An index definition can have only one synonym mapping. To learn more, see Define Synonym Mappings in Your Atlas Search Index. |