Skip to main content

๐Ÿ‘ Create an Atlas Search Index

To start using Atlas Search, you must configure a search index on your database. Atlas Search indexes categorized data in an easily searchable format and enable faster document retrieval using certain identifiers. You can create a search index right from the Atlas UI.

Step-by-step guide to creating your first Atlas Search indexโ€‹

Open the Database Deployments page in MongoDB Atlas and select Create Index in the lower right corner.

The 'Database Deployments' page with the 'Create Index' link highlighted

Click the Create Search Index button.

The 'Create Search Index' button highlighted

The first step of building the search index is selecting the configuration method. You can choose from two options โ€” using the Visual Editor or writing the configuration yourself with the JSON Editor. Let's stick to the default Visual Editor. To proceed, click Next.

The 'Configuration Method' step of creating a new search index

Next, you need to select a name and data source for your index. Change the name to fulltextsearch and select the database library and the collection books.

The 'Name & Data Source' step of creating a new search index

The final step allows you to review the index configuration and refine it if needed. You may also see the JSON that was generated from your configuration by clicking View JSON.

{
"mappings": {
"dynamic": true
}
}
info

The index is using dynamic field mappings. We didn't configure any explicit (static) mappings between the fields in the documents and the search index. That's why Atlas created dynamic mappings that match the data in the documents to some common field types such as double, string, array, int, and double. Dynamic mappings are useful when you're just getting started with Atlas Search or if your schema changes regularly. However, they take up more space compared to static mappings.

You don't need to refine this index. Go ahead and click Create Search Index.

The 'Review & Refine' step of creating a new search index

You'll be redirected to a page showing all of the search indexes used in your Atlas project. Creating the index should take up to a minute.

info

When your search index reaches status Active, you'll be able to see more information about the index โ€” for example, the number of indexed documents, the field mappings, and the index size. Notice also that you're using one out of the three free search indexes that come with your free M0 database.

The 'Search Indexes' page with the newly created index highlighted

Once you see your new index showing as Active in the list, you can move to the next step.