Atlas Vector Search Overview
On this page
You can use Atlas Vector Search to perform vector search on your data in Atlas. When you define an Atlas Vector Search index on your collection, you can seamlessly index vector data along with your other data and then perform vector search queries against the indexed fields.
Atlas Vector Search enables various search use cases, including semantic, hybrid, and generative search. By storing vector embeddings alongside your other data in Atlas, you can filter semantic search queries on other fields in your collection and combine semantic search with full-text search. By using Atlas as a vector database, you can also leverage vector search in AI applications and integrate it with popular AI frameworks and services.
Atlas Vector Search is supported on Atlas clusters running MongoDB version 6.0.11, 7.0.2, or later for ANN search and MongoDB version 6.0.16, 7.0.10, 7.3.2, or later for ENN search.
Note
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.
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.
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.
A vector's number of dimensions is determined by the embedding model used to create it. Moreover, a vector's number of dimensions equals the number of dimensions of the vector space in which the vectors are plotted in order to determine their similarity.
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, or vectorization, is the process of converting your data into vectors. These embeddings capture meaningful relationships in your data and enable tasks like semantic search and retrieval. To use Atlas as a vector database, you create embeddings by passing your data through an embedding model, and you store these embeddings as a field in the 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 how you configure your Atlas Vector Search index and affects your query results based on how the embedding model was trained. As a result, different models offer varying 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.
Use Cases
Atlas Vector Search supports the following types of vector search queries:
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.
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 storing data in Atlas, using Atlas Vector Search to retrieve relevant documents from your data, and leveraging an LLM to answer questions on your data. You can implement RAG locally or by integrating Atlas Vector Search with popular frameworks and services. To learn more, see Retrieval-Augmented Generation (RAG) with Atlas Vector Search.
AI Integrations
You can use Atlas Vector Search with popular chat and embedding 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 use Atlas as a vector database, build generative AI applications, and implement RAG from start to finish.
For example, by integrating Atlas Vector Search with open-source frameworks such as LangChain and LlamaIndex, you can build applications that answer questions about your data on top of popular LLMs.
To learn more and get started, see Integrate Vector Search with AI Technologies.
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: