Atlas Search Tutorials
You can learn how to set up and query an Atlas Search index with our interactive lab, use-case tutorials or video.
Learn with an Interactive Lab
Prerequisites
To complete the interactive lab, you must create the following in your Atlas account:
A project called
MDB_EDU
.A cluster called
myAtlasClusterEDU
.A database user called
myAtlasDBUser
with the passwordmyatlas-001
, and thereadWriteAnyDatabase
permission.
About the Lab
The following lab teaches you how to create an Atlas Search index with dynamic mapping. Then, you can run a query using the text operator and display the relevance of the matched document with its score.
Click the Launch button in the in-browser Integrated Development Environment to start the lab.
After completing the tutorial, see Operators to learn about the types of queries you can run.
Learn with Tutorials
Prerequisites
To complete these tutorials, you must have the following:
An Atlas cluster with MongoDB version 4.2 or higher.
The sample data loaded into your Atlas cluster.
One of the following applications to run queries on your Atlas cluster:
Note
You can also complete these tutorials with local Atlas deployments that you create with the Atlas CLI. To learn more, see Create a Local Atlas Deployment.
About the Tutorials
How to Build Applications with Atlas Search and Atlas App Services contains tutorials that describe how to use Atlas App Services and Atlas Search to build a search UI and add reverse search to your application.
The How to Check for Null and Non-Null Values with Atlas Search tutorial describes how to add documents containing
null
values and create a dynamic index on thesample_mflix.users
collection. The queries search thesample_mflix.users
collection fornull
and non-null
fields.The How to Paginate Query Results describes how to use
$skip
and$limit
after the$search
stage to paginate query results, and theSEARCH_META
Aggregation Variable to return the total documents found.The How to Define a Custom Analyzer and Run an Atlas Search Diacritic-Insensitive Query tutorial describes how to create an index that uses a custom analyzer and perform a diacritic-insensitive search against the
sample_mflix.movies
collection. The query searches thesample_mflix.movies
collection for movie titles that contain the given term regardless if the term contains diacritics.The How to Run an Atlas Search Compound Geo JSON Query tutorial describes how to create an index on the
sample_airbnb.listingsAndReviews
collection and run a query that returns documents with thename
,address
, andproperty_type
of each property within a specified polygon defined usingcoordinates
. Atlas Search results reflect a preference for properties of typecondominium
, and each document in the result is assigned a relevancescore
, returned in order from highest to lowest.The How to Run Atlas Search Compound Queries with Weighted Fields tutorial describes how to create a dynamic index and run compound queries with custom scoring. The queries search the
sample_mflix.movies
collection and alter the relevance score of the documents in the result usingconstant
,boost
, andfunction
options.The How to Run Multilingual Atlas Search Queries tutorial describes how to create an index that uses a language analyzer and perform a multilingual search against the
sample_mflix.movies
collection. The queries search thesample_mflix.movies
collection for full movie plots that contain a multilingual term.The How to Run Partial Match Atlas Search Queries tutorial describes how to create an index on the
sample_mflix.movies
collection and run case-sensitive partial match queries against the indexed field using autocomplete, phrase, regex, and wildcard operators.How to Run Atlas Search Queries Across Collections contains tutorials that describe how to run queries across multiple collections by first combining collections using
$lookup
, and$unionWith
, and then running$search
queries against the collections.The How to Run Atlas Search Queries Against Objects in Arrays tutorial demonstrates how to index fields of type string inside an array of objects and run Atlas Search queries against the indexed fields.
The How to Run Atlas Search Queries with a Date Range Filter tutorial describes how to create a dynamic index and run compound queries that use the
range
operator. The queries search thesample_mflix.movies
collection for movies between a specified date range.The How to Run Atlas Search String Queries Against Date and Numeric Fields tutorial describes how to run queries against numeric and date fields using operators that support only string queries. The queries search for properties that were listed on certain dates and allow them to stay up to a certain number of days.
The How to Sort Your Atlas Search Results tutorial describes how to index date, number, and string in the
sample_mflix.movies
for sorting and how to use the$search
sort
option to sort the results in ascending and descending order by the indexed fields.The How to Use Autocomplete with Atlas Search tutorial describes how to create and query an Atlas Search index configured with an
autocomplete
field using theautocomplete
operator. We will create the Atlas Search index on thesample_mflix.movies
collection and indextitle
field text values for autocompletion. We will run Atlas Search queries using theautocomplete
operator to search the indexed field for a sequence of characters.The How to Use Facets with Atlas Search tutorial describes how to create an index with a facet definition for the
sample_mflix.movies
collection and run queries against the faceted fields for results grouped by values and ranges in the specified, faceted fields, including a count for each of those groups.The How to Use Synonyms with Atlas Search tutorial describes how to add a collection that configures words as synonyms, create an index that defines synonym mappings on the
sample_mflix.movies
collection, and run Atlas Search queries against thetitle
field using words that are configured as synonyms.The Update $text Queries with Atlas Search for Improved Search Performance tutorial describes how you can replace
$text
aggregation pipeline stage in your query with$search
to improve both the flexibility and performance of these queries.The Use Atlas Search for Full-Text Regex Queries tutorial describes how you can replace inefficient regex matching with
$search
to improve the performance of text queries.The How to Perform Hybrid Search tutorial describes how to perform a semantic search against the
sample_mflix.embedded_movies
collection and combine the results with Atlas Search full-text search results by using the popular hybrid search technique known as reciprocal rank fusion.
Tip
Want more Atlas Search content?
Take Unit 9 of the Intro To MongoDB Course on MongoDB University for an overview of Atlas Search and lessons on creating Atlas Search indexes, running
$search
queries using compound operators, and grouping results using facet.Visit the MongoDB Developer Center for more real-world Atlas Search examples.
Try the full-text search examples in the Practical MongoDB Aggregations Book.
Learn with Videos
Follow along with this video to learn how to configure your Atlas Search index and run queries from your application.
Duration: 7 Minutes