Atlas Vector Search Overview
On this page
You can use Atlas Vector Search to perform vector search on your data stored in Atlas. Vector search allows you to query your data based on semantic meaning rather than just keyword matches, which helps you retrieve more relevant search results. It enables your AI-powered applications to support use cases such as semantic search, hybrid search, and generative search, including RAG.
By using Atlas as a vector database, you can seamlessly index vector data along with your other data in Atlas. This allows you to filter on fields in your collection and perform vector search queries against vector data. You can also combine vector search with full-text search queries to return the most relevant results for your use case. You can integrate Atlas Vector Search with popular AI frameworks and services to easily implement vector search in your applications.
Note
Atlas Vector Search supports ANN search on clusters running MongoDB v6.0.11, v7.0.2, or later and ENN search on clusters running MongoDB v6.0.16, v7.0.10, v7.3.2, or later.
What is Vector Search?
Vector search is a search method that returns results based on your data's semantic, or underlying, meaning. Unlike traditional full-text search which finds text matches, vector search finds vectors that are close to your search query in multi-dimensional space. The closer the vectors are to your query, the more similar they are in meaning.
By interpreting the meaning of your search query and data, vector search allows you to consider the searcher's intent and search context to retrieve more relevant results.
For example, if you searched for the term "red fruit," full-text search returns only data that explicitly contains these keywords. However, semantic search might return data that is similar in meaning, such as fruits that are red in color like apples or strawberries.
Use Cases
Atlas Vector Search supports the following vector search use cases:
Semantic Search: Query your vector embeddings based on semantic similarity by using the ANN or ENN search algorithm.
To learn more, see How to Perform Semantic Search and Run Vector Search Queries.
Hybrid Search: Combine results from both semantic search and full-text search queries. To learn more, see Perform Hybrid Search with Atlas Vector Search and Atlas Search.
Generative Search: By using Atlas as a vector database, you can use Atlas Vector Search to power your natural language processing (NLP), machine learning (ML), and generative AI applications. Specifically, you can implement retrieval-augmented generation (RAG) by doing the following:
Ingest data into Atlas.
Retrieve relevant documents with Atlas Vector Search.
Generate responses on your data by using an LLM.
To learn more, see RAG with Atlas Vector Search.
AI Integrations
You can use Atlas Vector Search with popular embedding and chat models from AI providers such as OpenAI, AWS, and Google. MongoDB and partners also provide specific product integrations to help you leverage Atlas Vector Search in your AI-powered applications. These integrations include built-in tools and libraries that enable you to implement RAG from start to finish.
To learn more, see Integrate Vector Search with AI Technologies.
Key Concepts
- vector
A vector is an array of numbers that represents your data in multiple dimensions. Vectors can represent any kind of data, from text, image, and audio data to unstructured data. Semantic similarity is determined by measuring the distance between vectors.
Vector dimensions refer to the number of elements in the array, and therefore the number of dimensions in vector space where the vectors are plotted.
Specifically, Atlas Vector Search uses dense vectors, which are a type of high-dimensional vector that favors smaller storage and semantic richness. As opposed to sparse vectors, dense vectors can be packed with more data, which enables Atlas Vector Search to capture more complex relationships.
- vector embeddings
Vector embeddings are vectors you use to represent your data. These embeddings capture meaningful relationships in your data and enable tasks like semantic search and retrieval. You create vector embeddings by passing your data through an embedding model, and you can store these embeddings in Atlas as a field in a document.
Atlas Vector Search determines semantic similarity by identifying the vector embeddings that are closest in distance to your query vector.
To learn more, see How to Create Vector Embeddings.
- embedding model
Embedding models are algorithms that you use to convert your data into vector embeddings. To do this, embedding models use LLMs, machine learning models trained on a large corpus of data, to generate vector embeddings that capture the semantic meaning of your data.
The embedding model that you choose determines the dimensions of your vector embeddings. You must specify these dimensions as a field in your Atlas Vector Search index.
Embedding models vary depending on how the model was trained. Therefore, different models offer different advantages depending on your data and use case. To learn more, see Choosing an Embedding Model.
Atlas Vector Search Indexes
To perform vector search on your data in Atlas, you must create an Atlas Vector Search index. Atlas Vector Search indexes are separate from your other database indexes and are used to efficiently retrieve documents that contain vector embeddings at query-time. In your Atlas Vector Search index definition, you index the fields in your collection that contain your embeddings to enable vector search against those fields. Atlas Vector Search supports embeddings that are less than and equal to 4096 dimensions in length.
You can also pre-filter your data by indexing any boolean, date, numeric, objectId, string, and UUID fields in your collection that you want to run your Atlas Vector Search queries against. Filtering your data narrows the scope of your search and ensures that certain vector embeddings aren't considered for comparison.
To learn how to index fields for Atlas Vector Search, see How to Index Fields for Vector Search.
Atlas Vector Search Queries
Atlas Vector Search supports approximate nearest neighbor (ANN) search with the Hierarchical Navigable Small Worlds algorithm and exact nearest neighbor (ENN) search.
To find the most similar vectors, Atlas Vector Search performs ANN search without scanning every vector embedding and ENN search exhaustively on all the indexed vector embeddings. To learn more, see vectorSearch Definition.
Atlas Vector Search queries consist of aggregation pipeline stages where the $vectorSearch
stage is the
first stage in the pipeline. The process for a basic Atlas Vector Search query
is as follows:
You select either ANN or ENN search and specify the query vector, which is the vector embedding that represents your search query.
Atlas Vector Search finds vector embeddings in your data that are closest to the query vector.
Atlas Vector Search returns the documents that contain the most similar vectors.
To customize your vector search query, you can pre-filter your data on fields that you've indexed by using an MQL match expression with supported query or aggregation operators, or you can add additional aggregation stages to further process and organize your results.
To learn how to create and run Atlas Vector Search queries, see Run Vector Search Queries.
Next Steps
For a hands-on experience creating Atlas Vector Search indexes and running Atlas Vector Search queries against sample data, try the Atlas Vector Search Course on MongoDB University and the tutorials in the following pages:
For optimal performance, we recommend deploying separate search nodes for workload isolation. Search Nodes support concurrent query execution to improve individual query latency. To learn more, see Review Deployment Options.