Navigation

Create an Atlas Search Index

Note

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

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.

Prerequisites

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

  • MongoDB version 4.2 or higher
  • At least one collection

Procedure

1
2

Click the Collections button on your desired cluster.

3

Select a namespace from the left-side panel.

Select a database, then select a collection for your Atlas Search index.

4

Click the Search Indexes tab in the right-side panel.

5

Click the Create Search Index button.

6

Specify a name for the index in the Name field.

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

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.

Screenshot of Create an Atlas Search Index modal window
7

Define field mappings.

By default, the new index uses dynamic field mappings, which allows Atlas Search to dynamically assign data types to fields. You can leave the default index structure in place or define one of your own.

Note

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

8

Click the Create Index button.

9

Close the In Progress Modal Window.

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

10

Check the status.

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

Note

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

Node Status

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.

Status Description
Not Started Atlas has not yet started building the index.
Initial Sync Atlas is building the index or re-building the index after an edit. In this state, Atlas Search does not serve queries.
Active Index is ready to use.
Failed Atlas could not build the index. Use the error in the View status details modal window to troubleshoot the issue.
Delete in Progress Atlas 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.