π 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.
Click the Create Search Index button.
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.
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 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
}
}
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.
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.
When your search index's status changes to Ready
, 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. Also notice that you're using one out of the three free search indexes that come with your free M0 database.
Once your new index's status is Ready
, you can move to the next step.