Note
Automated Embedding is in Preview for mongot in Kubernetes cluster. The feature and corresponding documentation might change at any time during the Preview period. To learn more, see Preview
Features.
This page describes how to configure Automated Embedding on your Kubernetes deployment of Vector Search. The Automated Embedding functionality in Vector Search generates vector embeddings for your text data at index-time and for query text at query-time. Therefore, you don't have to maintain a separate embedding pipeline in your application.
This tutorial is for developers who are building semantic search or RAG features and want mongot to manage embeddings.
What Automated Embedding Does
Without Automated Embedding, your application must:
Generate an embedding for each document that you insert or update.
Store that embedding alongside the document in your collection.
Generate an embedding for every query, using the same model, at query-time.
Submit the query embedding to
$vectorSearch.
With Automated Embedding, the mongot process handles steps 1, 2, and 3. Your application:
Configures a Vector Search index with the
autoEmbedfield type for the text field.Inserts and updates documents normally. Then,
mongotreads the text field, generates the embedding through the configured embedding model, and stores it.Issues
$vectorSearchqueries with the query text, not a pre-computed embedding. Then,mongotgenerates the embedding for the query text.
Supported Embedding Providers
Self-managed mongot Automated Embedding integrates with Voyage AI embedding models.
Model | Description |
|---|---|
| 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. |
You incur costs for embedding generation. To learn more, see Manage Billing for Automated Embedding.
Prerequisites
mongot1.70.1 or later in your Kubernetes deployment.MongoDB 8.2 or later.
Two Voyage AI API keys.
Use two separate keys, one for index-time embedding generation and one for query-time. Separate keys isolate query workload from indexing workload and allow independent rate-limit accounting. To learn more, see Rate Limits.
Outbound network access from
mongotto the embedding endpoint.The default endpoint is
https://ai.mongodb.com/v1/embeddings, which proxies Voyage AI with MongoDB-managed billing, for keys generated using the Atlas UI. You can also usehttps://api.voyageai.com/v1/embeddingsfor direct Voyage AI access if you generated the API key directly from Voyage AI.
Generate Voyage AI API Keys
You can generate Voyage AI API keys through either of the following paths:
(Recommended) Through your Atlas account. Atlas provides API key management with built-in rate-limit configuration. The keys are not tied to an Atlas cluster. To learn more, see Manage API Keys.
Through Voyage AI directly at voyageai.com.
Generate two keys and name them clearly, for example, mongot-prod-index and mongot-prod-query. Store the keys in secure secret storage.
Configure mongot for Automated Embedding
Create a Kubernetes Secret with both keys:
kubectl create secret generic voyage-api-keys \ --from-literal=indexing-key=<your-index-key> \ --from-literal=query-key=<your-query-key> \ --namespace=<your-namespace>
Reference it from the MongoDBSearch Custom Resource:
apiVersion: mongodb.com/v1 kind: MongoDBSearch metadata: name: mdbs spec: # ... autoEmbedding: embeddingModelAPIKeySecret: name: voyage-api-keys
Optionally, set spec.autoEmbedding.providerEndpoint to override the embedding endpoint that mongot uses. When you omit this field, mongot uses its built-in default endpoint, https://ai.mongodb.com/v1/embeddings. To learn more, see MongoDBSearch Resource Specification.
Create an Automated Embedding Index
After you configure mongot with your Voyage AI API keys, define a Vector Search index that uses the autoEmbed field type. The index definition specifies which text field mongot embeds, which model it uses, the indexing method, quantization, and other parameters. To learn more about the autoEmbed index definition, see MongoDB Vector Search Index Fields.
kubectl exec --context "${K8S_CTX}" -n "${MDB_NS}" mongodb-tools-pod -- \ mongosh --quiet "${MDB_CONNECTION_STRING}" \ --eval "use sample_mflix" \ --eval 'db.movies.createSearchIndex("vector_auto_embed_index", "vectorSearch", { "fields": [ { "type": "autoEmbed", "modality": "text", "path": "plot", "model": "'"${EMBEDDING_MODEL}"'", "numDimensions": 1024, "similarity": "cosine", "quantization": "scalar", "indexingMethod": "hnsw", "hnswOptions": { "maxEdges": 16, "numEdgeCandidates": 200 } } ] });'
The following table describes the autoEmbed index definition fields:
Field | Purpose |
|---|---|
| Marks the field for automatic embedding. |
| The data modality. |
| The field in your collection to embed. |
| The Voyage AI model name. The model must be one that your API key has access to. |
| The number of dimensions for the embedding vector. The model determines the supported dimensions. |
| The similarity function to use for vector search. The supported functions are |
| The indexing method to use. The supported methods are |
| (Optional) The HNSW index options. Required if |
| (Optional) The quantization type to use. The supported types are |
You can mix autoEmbed fields with filter fields in the same index. You cannot mix autoEmbed with raw vector fields on the same path.
Run an Automated Embedding Query
Submit query text, not a pre-computed embedding. mongot generates the query embedding for you.
kubectl exec --context "${K8S_CTX}" -n "${MDB_NS}" mongodb-tools-pod -- \ mongosh --quiet "${MDB_CONNECTION_STRING}" \ --eval "use sample_mflix" \ --eval 'db.movies.aggregate([ { $vectorSearch: { index: "vector_auto_embed_index", path: "plot", query: "spy thriller", numCandidates: 150, limit: 10 } }, { $project: { _id: 0, plot: 1, title: 1, score: { $meta: "vectorSearchScore" } } }]);'
To learn more, see Run Vector Search Queries.
Embedding Storage
mongot persists embeddings in a dedicated internal database on the Kubernetes cluster. mongot does not store embeddings in your source collection. mongot can regenerate embeddings from the source text, and you incur charges for embedding generation.
Changes to the embedding model, output dimensions, or quantization trigger a full re-embedding of the affected index. You incur charges for the regeneration. To learn more, see When mongot Regenerates Embeddings.
To learn more, see Generated Embeddings Collection.
When mongot Regenerates Embeddings
mongot regenerates embeddings for an autoEmbed field when any of the following occur:
You insert a document.
You change the embedded field in a document.
mongotdetects the change through change streams.You change the embedding model in the index definition.
You change the embedding output dimension or data type.
You change the text field path.
If you change any of the last three items, mongot rebuilds the entire index from scratch. The rebuild can be costly for large collections. Plan model changes deliberately.
Cost and Rate Limiting
MongoDB charges per million tokens at model-specific rates. Indexing cost is proportional to the total text volume of the indexed field across the collection. Query cost is proportional to the volume of query text.
If you use the Voyage AI API key that you created using your Atlas account, you can view API key usage and rate limits in the Atlas UI. To learn more, see Manage Billing for the Embedding and Reranking API. If you use keys created directly from Voyage AI, you must monitor your usage and rate limits in the Voyage AI dashboard.
Voyage AI-side rate-limit errors appear in mongot logs and as failed-document indicators on the affected index. These errors do not disable the index, but they can delay indexing of new documents.
Failure Modes
Symptom | Likely Cause |
|---|---|
The index stays in |
|
Indexing delays appear intermittently. | Voyage AI-side rate limiting. Either increase your rate limit or reduce indexing-time embedding load. |
Queries against the index return an error that mentions embeddings. | The query API key is invalid or expired. Verify the contents of |
All queries against the index return empty results. | The index might have been rebuilt and is still re-embedding the corpus. Check the index status with |
Limitations
Preview status. Configuration shape, supported models, and default endpoints might change before Automated Embedding is generally available.
One embedding model per field. Mixed-model indexes are not supported.
No embedding model failover. If the Voyage AI endpoint is unreachable, indexing of new documents stalls.