重要
Automated Embedding is in Preview for self-managed mongot. The feature and corresponding documentation might change at any time during the Preview period. To learn more, see Preview Features.
This tutorial describes how to configure Automated Embedding on a self-managed mongot deployment. With Automated Embedding, mongot generates vector embeddings for your text data at index-time and for query text at query-time. 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, mongot handles steps 1, 2, and 3. Your application:
Configures a MongoDB Vector Search index with the
autoEmbedfield type for the text field.Inserts and updates documents normally.
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.mongotgenerates the embedding for the query text.
Supported Embedding Providers
Self-managed mongot Automated Embedding integrates with Voyage AI embedding models.
モデル | 説明 |
|---|---|
| Recommended. Balanced performance for general text search. |
| High-volume, cost-sensitive applications. |
| 複雑なセマンティック関係の最大精度。 |
| コード検索と技術ドキュメントに特殊化されています。 |
You incur costs for embedding generation. To learn more, see Manage Billing for Automated Embedding.
前提条件
You must have the following prerequisites to use Automated Embedding:
mongot1.70.1 or later on a self-managed deployment (Community tarball or container, Local Development, and Enterprise Edition through Kubernetes Operator).MongoDB 8.2以降。
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. This endpoint 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 methods:
(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.
The configuration depends on your deployment path. Select the tab for your deployment.
Automated Embedding requires the preview Local Development image (mongodb/mongodb-atlas-local:preview). The preview image bundles the Community build of mongot, which includes the Automated Embedding integration.
If you launch the container directly with docker run, pass the Voyage AI API key with the VOYAGE_API_KEY environment variable and use the :preview tag:
docker run \ -e VOYAGE_API_KEY=<your-voyage-api-key> \ -p 27017:27017 \ mongodb/mongodb-atlas-local:preview
If you issued your Voyage AI key directly through Voyage AI rather than through Atlas, override the default endpoint:
docker run \ -e VOYAGE_API_KEY=<your-voyage-api-key> \ -e EMBEDDING_PROVIDER_ENDPOINT=https://api.voyageai.com/v1/embeddings \ -p 27017:27017 \ mongodb/mongodb-atlas-local:preview
注意
Local Development accepts only a single Voyage AI API key and uses it for both index-time and query-time embedding generation. A single key is acceptable for development. For production deployments that need separate index-time and query-time keys, use the Community Edition or Kubernetes Operator deployment path.
Add the embedding block to your mongot configuration file:
embedding: queryKeyFile: /etc/mongot/secrets/voyage-api-query-key indexingKeyFile: /etc/mongot/secrets/voyage-api-indexing-key providerEndpoint: https://ai.mongodb.com/v1/embeddings
Each key file contains the API key as its only content. Set the file permissions to 0600 and set the file owner to the user that runs the mongot process.
Create an Automated Embedding index.
After you configure mongot with your Voyage AI API keys, define a MongoDB Vector Search index that uses the autoEmbed field type. The index definition specifies which text field mongot embeds and which model it uses. It also specifies the indexing method, quantization, and other parameters.
db.movies.createSearchIndex( "movie-semantic-index", "vectorSearch", { "fields": [ { "type": "autoEmbed", "modality": "text", "path": "plot", "model": "voyage-4", "numDimensions": 1024, "similarity": "cosine", "indexingMethod": "hnsw", "hnswOptions": { "maxEdges": 16, "numEdgeCandidates": 50 }, "quantization": "scalar" }, { "type": "filter", "path": "genre" } ] } )
The following table describes the autoEmbed index definition fields:
フィールド | 目的 |
|---|---|
| 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. Choose one approach per field.
Run an Automated Embedding Query.
Submit query text, not a pre-computed embedding. mongot generates the query embedding for you.
db.movies.aggregate([ { "$vectorSearch": { "index": "movie-semantic-index", "path": "plot", "query": "a heist gone wrong in a rainy city", "model": "voyage-4", "numCandidates": 100, "limit": 10 } }, { "$project": { "_id": 0, "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 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, for which you incur charges for embedding generation. 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
シンボリック | 考えられる原因 | アクション |
|---|---|---|
The index stays in |
| Check |
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 |
制限
The following limitations apply to Automated Embedding:
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.
次のステップ
Automated Embedding Overview for the cross-platform conceptual overview.
Configure mongot for the full
mongotconfiguration reference.