Atlas Search Overview
On this page
What is Atlas Search?
Atlas Search is an embedded full-text search that gives you a seamless, scalable experience for building relevance-based app features and eliminates the need to run a separate search system alongside your database.
You can use Atlas Search for fine-grained text indexing and querying of data on your cluster. Atlas Search provides several kinds of text analyzers, a rich query language to create complex search logic, customizable score-based results ranking, and advanced search features for your applications like autocomplete, pagination, and faceting.
Use Cases
Atlas Search supports diverse use cases including the following:
Search-as-you-type: To predict words with increasing accuracy as users enter characters in your application's search field, you can use the Atlas Search autocomplete operator to predict and return results for partial words. To learn more, see How to Run Autocomplete and Partial Match Atlas Search Queries.
Faceted Search: To enable users of your application to narrow down search results through the use of filters, you can use the Atlas Search facet collector to build facets that group results by values or ranges in the faceted fields. To learn more, see How to Use Facets with Atlas Search.
Paginated Results: To group pages of results and implement functions like "Next Page" and "Previous Page", you can use the Atlas Search
searchSequenceToken
withsearchAfter
andsearchBefore
options to traverse pages in-order and jump across pages. To learn more, see How to Paginate the Results.
Key Concepts
The following concepts form the basis of Atlas Search and are essential to optimize your application.
What are search queries?
Search queries consult a search index to return a set of results. Search queries are different than traditional database queries, as they are intended to meet more general information needs. Where a database query must follow a strict syntax, search queries can be used for simple text matching, but can also look for similar phrases, number or date ranges, or use regular expressions or wildcards.
Atlas Search queries take the form of an aggregation pipeline stage. Atlas Search provides $search
and
$searchMeta
stages, which can be used in conjunction with
other aggregation pipeline stages in your query
pipeline. Atlas Search provides query operators and
collectors that you can use inside these
aggregation pipeline stages.
To learn more, see Queries and Indexes.
What is a search index?
In the context of search, an index is a data structure that categorizes data in an easily searchable format. Search indexes enable faster retrieval of documents that contain a given term without having to scan the entire collection. While both Atlas Search indexes and MongoDB Indexes make data retrieval faster, note that they are not the same. Like the index in the back of a book, a search index is a mapping between terms and the documents that contain those terms. Search indexes also contain other relevant metadata, such as the positions of terms in documents.
You can create an Atlas Search index on a single field or on multiple fields by using static mappings. Alternatively, you can enable dynamic mappings to automatically index all the dynamically indexable fields in your documents. You can create Atlas Search indexes on polymorphic data and embedded documents, or for specific use-cases like search-as-you-type or faceted search.
To learn more, see Manage Atlas Search Indexes.
What are search analyzers and tokens?
When creating a search index, data must first be transformed into a sequence of tokens or terms. An analyzer facilitates this process through steps including:
Tokenization: Breaking up words in a string into indexable tokens. For example, dividing a sentence by whitespace and punctuation.
Normalization: Organizing data so that it is consistently represented and easier to analyze. For example, transforming text to lower case or removing unwanted words called stop words.
Stemming: Reducing words to their root form. For example, ignoring suffixes, prefixes, and plural word forms.
The specifics of tokenization are language-specific and can require making additional choices. Which analyzer to use depends on your data and application.
Atlas Search provides some built-in analyzers. You can also create your own custom analyzer. You can specify alternate analyzers using multi analyzer.
To learn more, see Process Data with Analyzers.
What is a search score?
Each document in the query results receives a relevancy score that enables query results to be returned in order from the highest relevance to the lowest. In the simplest form of scoring, documents score higher if the query term appears frequently in a document and lower if the query term appears across many documents in the collection. Scoring can also be customized. Tailoring search to a specific domain often means customizing the relevance-based default score by boosting, decaying, or modifying it in other ways.
To learn more, see Score Documents.
Next Steps
For a hands-on experience creating Atlas Search indexes and running Atlas Search queries against sample data, try the Atlas Search Quick Start.