An MongoDB Search index is a data structure that maps documents from your Atlas cluster to the terms that are extracted from those documents. MongoDB Search indexes enable efficient full-text searches of your database.
When you define an MongoDB 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 MongoDB 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 MongoDB Search query, including options to store source fields in your index, or
define synonym mappings.
To learn how to define an MongoDB Search index according to your your query requirements, see Manage MongoDB Search Indexes. Once you define your MongoDB Search index, you can add the index to your Atlas cluster with the Create an MongoDB Search Index tutorial. To learn how to view, edit, update, or delete your MongoDB Search index, see Supported Clients.
This page describes the JSON syntax and definition options for an MongoDB Search index.
Syntax
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, MongoDB 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: MongoDB 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. |
| 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 MongoDB Search. Value can be one of the following:
If omitted, defaults to To learn more, see Define Stored Source Fields in Your MongoDB 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 MongoDB Search Index. |
Troubleshoot Indexes
mongot
Process Not Installed or Running
The following error is returned if you run $search
queries when
the MongoDB 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 MongoDB Search index is
defined. If you don't have any MongoDB Search index in your Atlas cluster,
create at least one MongoDB Search index to resolve this error.
Learn More
To learn how to define an MongoDB Search index to meet your MongoDB Search query needs, see Manage MongoDB Search Indexes.
To learn how to add an index to your Atlas cluster, see Create an MongoDB Search Index.
To learn more about the available index configuration options, see the following reference pages: