Lesson 1: Managing Atlas Search Indexes via the Atlas UI / Learn

Video Transcript (English)

It’s time to get to work and see about managing search indexes in the Atlas UI.

In this video, we’ll look at a simple search index from our movie catalog app.

Note that we need the proper permissions in Atlas in order to create and manage search indexes.

Specifically, we must have the Project Data Access Admin role or higher.

Atlas also has the Project Search Index Editor role, which limits us to managing search indexes with the Atlas UI and API.

For a more nuanced look at Atlas roles, check out the MongoDB documentation.

Now let’s create our search index in the Atlas UI.

Keep in mind that we regularly update the Atlas UI, so you may see a slightly different interface.

On the Atlas cluster dashboard, we select the cluster that holds the data for the movie catalog application.

Then we click the search tab.

We can create a new search index by clicking the Create Index button.

Now let’s choose whether to use the visual editor or the JSON editor.

The visual editor is a user-friendly interface to configure an Atlas Search index, and is great for beginners. Let’s start with this.

We must name our index and select a collection. In this case, we name it “plot index” and select the movies collection from the sample_mflix database.

We click Next when we’re done.

On the next screen, we see the default configuration for our new index.

For instance, dynamic mappings are selected. This means all supported field types in the collection will be indexed.

To further customize our search index, we click “Refine Your Index”.

Next, we choose specific fields to index rather than indexing the entire document. This helps us keep our index size down.

To do this, we toggle dynamic mapping off and select the option to add field mappings.

Then we select which field we want to index and its data type.

Let’s index the plot field because we want to be able to easily search phrases that appear in a movie's plot. We know this field has a string data type, so we select string from the drop-down menu.

We can further customize our search index by using the options under String Properties. 

Once complete, we click the Add button.

Now under Field Mappings, we can see that we’re indexing the plot field.

With that finished, we save our changes.

Back on the Create Index page, we can review our search index before creating it.

Everything looks correct, so let’s go ahead and create the search index.

A window will pop up to let us know that our search index is being deployed.

We can close this window to see the status of the index creation.

It may take a few minutes to complete, depending on the size of the collection.

Now that we’ve explored the visual editor, let’s go through a quick example with the JSON editor.

The JSON editor allows us to manually configure our search index through code. It has autocompletion, which displays the configurable settings for each field type.

This is a good option for those who have experience with creating search indexes.

Like before, we click the Create Index button.

Then select the JSON Editor.

We give our index a name and specify the collection.

This time, let’s create an index on the theaters collection in the sample_mflix database and name it theaterIndex.

But we also need to configure the index using JSON such that all fields get indexed.

Thankfully, the default JSON generated by Atlas Search already does this, so we don’t have to write it.

On the next page, we review the index.

Everything is correct, so let’s go ahead and create it.

Like before, a window appears to confirm that our search index is being built.

We can also check the status of the build.

In addition to creating indexes, the Atlas UI also makes it easy to test them.

Let’s test the plot index we created by clicking the Query button next to the search index.

We’ll see a search bar along with a list of documents.

We can type a phrase in the search bar such as “nature,” which will return a list of documents and their relevance score.

We can take this a step further and edit the generated search query code by clicking the Edit Search Query button.

Here, we can edit the $search stage code or copy it to use somewhere else.

When we’re done, we can easily exit the code editor by clicking the exit button.

So far, we’ve covered how to create and test search indexes in the Atlas UI.

Now let’s look at how to change them.

All we have to do is click the ellipsis button on one of the search indexes and select edit or delete.

Keep in mind that changes may take a few minutes to complete.

The good news is that your old index is usable until your new one has finished building.

Awesome job! In this video, you learned that we need the Project Data Access Admin or Project Search Index Editor roles in Atlas to manage search indexes using the Atlas UI.

Then, you learned how to use the Atlas UI to create, test, edit, and delete search indexes.

Until we meet again, keep learning!