Build a Dynamic Index
In this guide, you will learn how to create a search index for relevance-based search as an alternative to document-based search.
Time required: 15 minutes
What You'll Need
A MongoDB account. See Sign Up for a MongoDB Account.
An Atlas cluster. See Create a Cluster.
Sample datasets loaded into your cluster.
Navigate to the Database Deployments page for your project.
Click the Collections tab.
Create a dynamic search index.
In the right-hand pane, click
then click the
Click Search Indexes in the upper right of the collection preview pane.
Click Create Search Index.
Click the Visual Editor configuration method, then click Next.
Review the Database and Collection list to
sample_supplies.sales is selected, then click
Click QUERY in the Actions column of your index definition.
Run a query on your index.
notepad into the search bar, then click
Review the results.
Your results should include the fields listed in the following sample documents.
SCORE: 0.20185701549053192 salesDate: 2013-03-07T09:27:58.283+00:00 items: Array storeLocation: "Austin" SCORE: 0.20185701549053192 salesDate: 2013-05-05T19:03:06.358+00:00 items: Array storeLocation: "London" SCORE: 0.20185701549053192 salesDate: 2016-06-20T14:09:52.408+00:00 items: Array storeLocation: "Denver"
Each record also includes a relevance score.
You can expand
Object fields to view their
contents by clicking on them.
Click Edit Query Syntax. The modal window displays the query sent through the Atlas Search API.
If you successfully completed the procedure in this guide, you have
created an Atlas Search index with dynamic field mappings and used it
to perform a relevance-based query against the
sample_supplies.sales collection. In the next guide, you will learn
how to perform a refined search by creating an index with static field
Retrieve documents in MongoDB with a field-specific query.