You can deploy MongoDB Vector Search and enable intelligent, AI-powered semantic search on your text data through automated embedding in MongoDB Vector Search indexes. MongoDB's automated embedding capabilities transform the traditionally complex process of vector search implementation into a single-step solution. Instead of managing separate embedding infrastructure, model selection, and integration code, you can now implement semantic search through simple field configuration.
When you configure MongoDB Vector Search indexes, it automatically generates vector embeddings for text data in your collection, using your selection of a state-of-the-art Voyage AI embedding model, keeps the embeddings in sync as your data changes, and also supports use of natural language text queries. These vector embeddings capture meaningful relationships in your data and allow for searching based on intent rather than keywords.
Overview
With a simple configuration change, you can enable semantic search, RAG, and memory for AI Agents, without writing embedding code,
managing model infrastructure, or handling vector pipelines. That is, when
deploying the MongoDB Community Edition with the MongoDB Search
and Vector Search process, mongot,
you can provide the Voyage AI API keys
to use for generating embeddings, ideally one for indexing operations and
another for query operations from different projects.
After deployment:
From your collection, choose the text field for which you want to enable the semantic search.
From the list of available embedding models, choose an embedding model.
In your MongoDB Vector Search index definition, configure automated embeddings using the
autoEmbedtype.
To learn more about configuring MongoDB Vector Search index for automated embedding, see Index a Text Field.
MongoDB Vector Search automatically generates embeddings for existing and new documents that you insert or update by using the API keys that you specified while initializing MongoDB Community Edition.
Note
The generated embeddings are stored in a separate system collection on the same cluster.
For querying, use the query.text option in the $vectorSearch
pipeline stage. MongoDB Vector Search generates embeddings for the text query using the
same embedding model in the index definition. You can specify a different
embedding model using the model option in the $vectorSearch
pipeline stage, but the specified embedding model must be compatible with
the embedding model used at index-time. MongoDB Vector Search uses the query API key that
you provided during MongoDB Community initialization to generate the
embeddings at query-time. To learn more, see Run a Text Query.
You will incur charges for generating embeddings using the API keys. To learn more, see Costs.
To automate embeddings and run a sample query, see Get Started.
Voyage AI API Keys
While you can use a single API key for generating embeddings at index-time and at query-time, we recommend that you use separate API keys to avoid query operations from negatively impacting indexing operations.
You can generate API keys in the following ways:
(Recommended) Using your Atlas account, which allows you to manage your Voyage AI embedding model API key from the Atlas UI.
To learn more about generating and managing API keys including configuring the rate limits (which is a combination of TPM and RPM) and monitoring API key usage, see Model API Keys.
To learn more about managing the API keys created from Voyage AI, see API Key.
After creating the keys, you must specify the keys you want to use for
automated embedding when configuring mongot during deployment with MongoDB Community Edition. MongoDB Vector Search
uses the Voyage AI API key that you provided during deployment of
mongot to automatically generate embeddings for your data at index-
and for your query text at query-time.
Supported Embedding Models
MongoDB Vector Search integrates with Voyage AI's state-of-the-art embedding models, each optimized for specific use-case:
Embedding Model | Description |
|---|---|
| Optimized for high-volume, cost-sensitive applications. |
| (Recommended) Balanced performance for general text search. |
| Maximum accuracy for complex semantic relationships. |
| Specialized for code search and technical documentation. |
Costs
Embedding model pricing is usage-based, with charges billed to the account linked to the API key used for access. Pricing is based on the number of tokens in your text field and queries.
Note
In the context of embedding models and LLMs, tokens are the fundamental units of text, such as words, subwords, or characters, that the model processes to create embeddings or generate text. Tokens are how you are billed for usage of embedding models and LLMs.
If you use the API key that you created using your Atlas account, you can monitor API key usage from the Atlas UI. To learn more, see Billing.
If you generated the API key directly from Voyage AI, see Pricing to learn more about the charge for requests to the embedding service endpoint.
Limitations
While in Preview, automated embedding functionality is not yet available for the following deployment types:
Atlas clusters
Local Atlas deployments using the Atlas CLI
MongoDB Enterprise Edition
The feature is only available for MongoDB Search and MongoDB Vector Search deployments using Docker, tarball, or a package manager and for deployments using the MongoDB Controllers for Kubernetes Operator with MongoDB 8.2 or later Community Edition.
Get Started
Use the following tutorial to learn how to configure MongoDB Vector Search to automatically generate vector embeddings. Specifically, you perform the following actions:
Index the field or fields in your collection that contain text data for which you want to automatically generate embeddings at index-time.
Run a text query against the indexed fields using automatically generated embeddings at query-time.
This tutorial uses the sample_airbnb.listingsAndReviews namespace to demonstrate how to index a text field,
summary, in the collection for automatically generating embeddings
at index-time and run a text query against the indexed field,
summary, using embeddings generated at query-time.
Prerequisites
To complete this tutorial, you must have the following:
Self-managed deployment of MongoDB v8.2 or later Community Edition with MongoDB Search and MongoDB Vector Search
To learn more, see Install MongoDB Community Edition.
Valid Voyage AI API key or keys
To learn more, see Voyage AI API Keys.
Index a Text Field
The index definition that you create in this tutorial indexes the
following fields in the sample_airbnb.listingsAndReviews
collection:
summaryfield as theautoEmbedtype to automatically generate embeddings for the text data in the field using thevoyage-4embedding model.address.countryfield as thefiltertype to prefilter the data for the semantic search using the string value in the field.bedroomfield as thefiltertype to prefilter the data for the semantic search using the numeric value in the field.
To create this index:
Run a Text Query
The query in this tutorial does the following:
Runs against the the indexed
summaryfield in thesample_airbnb.listingsAndReviewscollection.Prefilters the properties using the following criteria:
Properties that have
3or morebedrooms.Properties in the
countrynamedUnited States.
Performs a semantic search for properties that are
close to amusement parksusing the embeddings automatically generated with thevoyage-4embedding model. The query:Considers up to
100nearest neighbors.Limits the results to
10documents.
To run this query: