Docs Menu

Index Reference

An Atlas Search index is a data structure that maps documents from your Atlas cluster to the terms that are extracted from those documents. Atlas Search indexes enable efficient full-text searches of your database.

When you define an Atlas Search index, you can use static or dynamic mappings to specify which fields you want to index in your collection. You can also use analyzers to define how Atlas Search extracts searchable tokens from string fields or query strings. Finally, you can apply additional configuration options in your index definition to improve the performance and accuracy of your Atlas Search query, including options to store source fields in your index, or define synonym mappings.

To learn how to define an Atlas Search index according to your your query requirements, see Create an Atlas Search Index. Once you define your Atlas Search index, you can add the index to your Atlas cluster with the Create an Atlas Search Index tutorial. To learn how to view, edit, update, or delete your Atlas Search index, see Manage Atlas Search Indexes.

This page describes the JSON syntax and definition options for an Atlas Search index.

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": <integer>,
9 "analyzers": [ <custom-analyzer> ],
10 "storedSource": <boolean> | {
11 <stored-source-definition>
12 },
13 "synonyms": [
14 {
15 <synonym-mapping-definition>
16 }
17 ]
18}
19
Field
Type
Necessity
Description

analyzer

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.

analyzers

Optional

Specifies the Custom Analyzers to use in this index.

mappings

Required

Specifies how to index fields at different paths for this index.

mappings.dynamic

boolean

Optional

Enables or disables dynamic mapping of fields for this index.

If set to true, Atlas Search recursively indexes all dynamically indexable fields.

If set to false, you must specify individual fields to index using mappings.fields.

If omitted, defaults to false.

IMPORTANT: Atlas Search dynamically indexes all fields in a document using the default settings for the detected data type. Atlas Search also dynamically indexes all nested documents under the document, unless you explicitly override by setting dynamic to false.

For example index configurations, see Static Mapping Example or Combined Mapping Example

mappings.fields

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 ($) sign at the start of the field name.

To learn more, see Define Field Mappings.

searchAnalyzer

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 analyzer option. If you omit both the searchAnalyzer and the analyzer options, defaults to the Standard Analyzer.

numPartitions

int

Optional

Specifies the number of sub-indexes to create if the document count exceeds two billion. The following values are valid: 1, 2, 4. If omitted, defaults to 1.

To use index partitions, you must have search nodes deployed in your cluster.

storedSource

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:

  • true, to store all fields

  • false, to not store any fields

  • Object that specifies the fields to include or exclude from storage

storedSource is only available on Atlas clusters running one of the following versions:

  • MongoDB 5.0.6+

  • MongoDB 6.0+

  • MongoDB 7.0+

If omitted, defaults to false.

To learn more, see Define Stored Source Fields in Your Atlas Search Index.

synonyms

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.

The following error is returned if you run $search queries when the Atlas Search mongot process isn't installed or running:

MongoError: Remote error from mongot :: caused by :: Error connecting to localhost:28000.

The mongot process is installed only when the first Atlas Search index is defined. If you don't have any Atlas Search index in your Atlas cluster, create at least one Atlas Search index to resolve this error.

To learn how to define an Atlas Search index to meet your Atlas Search query needs, see Create an Atlas Search Index.

To learn how to add an index to your Atlas cluster, see Create an Atlas Search Index.

To learn more about the available index configuration options, see the following reference pages: