构建动态索引
概述
In this guide, you will learn how to create an Atlas Search index with dynamic mappings to query and quickly retrieve relevant data.
所需时间:5 分钟
您需要的工具
一个 MongoDB 帐户。请参阅注册 MongoDB 帐户。
Atlas 集群。请参阅创建群集。
加载到集群中的示例数据集。
步骤
Navigate to the Database Deployments page for your project.
Create a dynamic search index.
单击 Create Search Index(连接)。
Select the Visual Editor configuration method, then click Next.
对于Database and Collection ,选择 sample_supplies
数据库和sales
collection。 然后,单击Next 。
Click Create Search Index to confirm your selection. Wait for the Status column to read Active.
You now have a search index that dynamically indexes the fields across the documents in your collection.
Run a query on your index.
Click Query in the Actions column of your index definition.
Type notepad
into the search bar, then click Search.
This query returns all documents in the sales
collection with a field that contains notepad
.
Review the results.
Your results should resemble 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 Array
and 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 mappings.