On this page
Starting in v6.0, the MongoDB
$lookup aggregation stage
$search inside the
pipeline option. Using
$lookup, you can join
multiple collections in the same database at query-time and run a
$search query to further narrow down your search.
Set up an Atlas Search index with dynamic mapping for the
accountscollection in the
Before you begin, ensure that your Atlas cluster meets the requirements described in the Prerequisites.
To create an Atlas Search index, you must have
Project Data Access Admin or higher access to the project.
Create an Atlas Search index named
lookup-with-search-tutorial on all the
fields in the
If it is not already displayed, select the organization that contains your desired project from the Organizations menu in the navigation bar.
If it is not already displayed, select your desired project from the Projects menu in the navigation bar.
Click your cluster's name.
Click the Atlas Search tab.
In the Index Name field, enter
If you name your index
default, you don't need to specify an
indexparameter when using the $search pipeline stage. Otherwise, you must specify the index name using the
In the Database and Collection section, find the
sample_analyticsdatabase, and select the
The following index definition dynamically indexes the fields of supported types in the collection. You can use the Atlas Search Visual Editor or the Atlas Search JSON Editor in the Atlas user interface to create the index.
➤ Use the Select your language drop-down menu on this page to set the language of the examples in this section.
Connect to your Atlas cluster and run the sample query against the
indexed collections in the