Navigation

Create an Atlas Search Index

Info With Circle IconCreated with Sketch.Note

You can also create and manage Atlas Search indexes with the Atlas API.

Important With Circle IconCreated with Sketch.Important

If you use the $out aggregation stage to modify a collection with an Atlas Search index, you must delete and re-create the search index. If possible, consider using $merge instead of $out.

To create an Atlas Search index, you must have an Atlas cluster with:

  • MongoDB version 4.2 or higher
  • At least one collection
1
2
3
4
  • For your first index, click Create Search Index.
  • For subsequent indexes, click Create Index.
5
  • For a guided experience, select Visual Editor.
  • To edit the raw index definition, select JSON Editor.
6
  1. In the Database field, specify the database name.
  2. In the Collection field, specify the collection name.
  3. In the Index Name field, specify a name for the index.

    The index name defaults to default. You can leave the default name in place or choose one of your own.

    Info With Circle IconCreated with Sketch.Note

    If you name your index default, you don't need to specify an index parameter when using the $search pipeline stage. Otherwise, you must specify the index name using the index parameter.

    Index names must be unique within their namespace.

  4. If you use the Visual Editor, click Next.
7

If you are satisfied with the default configuration, skip to step 9. If you wish to refine your Atlas Search index, proceed to the next step.

Info With Circle IconCreated with Sketch.Note

Defining your own field mappings is recommended for advanced users only.

8

Click Refine Your Index to make changes to any of the following settings and click Save Changes.

Field NameDescriptionNecessity
Index AnalyzerSelect the analyzer to use for indexing the collection data from the dropdown. By default, Atlas Search uses the standard analyzer.Optional
Query AnalyzerSelect the analyzer to use when parsing data for the Atlas Search queries from the dropdown. By default, Atlas Search uses the standard analyzer.Optional
Dynamic MappingSelect dynamic or static mapping of fields. To disable dynamic mapping, set Dynamic Mapping to Off. By default, dynamic mapping is enabled. If you disable dynamic mapping, you must specify the fields to index. To learn more about dynamic and static mappings, see Index Definitions.Required
Field Mappings

Required if dynamic mapping is disabled.

To add the fields to index, click Add Field. You must specify the following settings for each field:

  • Field name.
  • Static or dynamic mapping. If you disable dynamic mapping, all BSON data in the field will not be automatically indexed.
  • Field data type. Click Add Data Type and select the data type from the dropdown. To learn more about the available data types and their options, see BSON Data Types and Atlas Search Data Types.
Conditional
9
10

A modal window appears to let you know your index is building. Click the Close button.

11

The newly created index appears on the Search tab. While the index is building, the Status field reads Build in Progress. When the index is finished building, the Status field reads Active.

Info With Circle IconCreated with Sketch.Note

Larger collections take longer to index. You will receive an email notification when your index is finished building.

The Atlas Search Indexes tab in the right-side panel of the Atlas UI displays information about Atlas Search indexes for the selected namespace. The Status column shows the current state of the index on the primary node of the cluster. Click the View status details link below the status to view the state of the index on all the nodes of the cluster.

Screenshot of Atlas Search Index information panel

When the Status column reads Active, the index is ready to use. In other states, queries against the index may return incomplete results.

StatusDescription
Not StartedAtlas has not yet started building the index.
Initial SyncAtlas is building the index or re-building the index after an edit. In this state, Atlas Search does not serve queries.
ActiveIndex is ready to use.
FailedAtlas could not build the index. Use the error in the View status details modal window to troubleshoot the issue.
Delete in ProgressAtlas is deleting the index from the cluster nodes.

When and after Atlas builds the index, the Documents column shows the percentage and number of documents indexed. The column also shows the total number of documents in the collection.

Give Feedback