Página inicial do Docs → Começar com Guias
Crie um índice dinâmico
Visão geral
In this guide, you will learn how to create an Atlas Search index with dynamic mappings to query and quickly retrieve relevant data.
Tempo necessário: 5 minutos
O que você precisa
Uma conta MongoDB. Consulte Inscrever-se em uma conta MongoDB.
Um Atlas cluster. Consulte Criar um cluster.
Exemplos de conjuntos de dados carregados em seu cluster.
Procedimento
Navigate to the Database Deployments page for your project.
Create a dynamic search index.
Clique em Create Search Index.
Select the Visual Editor configuration method, then click Next.
Para o Database and Collection, selecione o reconhecimento de data center sample_supplies
e a collection sales
. Em seguida, clique em 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.
Resumo
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.
Retrieve documents in MongoDB with a field-specific query.