Class MongoVectorStore
java.lang.Object
com.google.genkit.plugins.mongodb.MongoVectorStore
MongoDB Atlas Vector Search-backed vector store.
Indexes documents into a collection with an embedding field and retrieves them with the
$vectorSearch aggregation stage. Requires an Atlas Vector Search index; use the
mongodb/mongodb-atlas-local Docker image for local development or a MongoDB Atlas cluster.
-
Constructor Summary
ConstructorsConstructorDescriptionMongoVectorStore(com.mongodb.client.MongoClient client, MongoVectorStoreConfig config, Embedder embedder) Creates a new store. -
Method Summary
Modifier and TypeMethodDescriptionindex(ActionContext context, IndexerRequest request) Indexes documents into the collection, generating an embedding for each.retrieve(ActionContext context, RetrieverRequest request) Retrieves documents similar to the query using the$vectorSearchaggregation stage.
-
Constructor Details
-
MongoVectorStore
public MongoVectorStore(com.mongodb.client.MongoClient client, MongoVectorStoreConfig config, Embedder embedder) Creates a new store.- Parameters:
client- the MongoDB clientconfig- the collection configurationembedder- the embedder used to vectorize documents and queries
-
-
Method Details
-
retrieve
Retrieves documents similar to the query using the$vectorSearchaggregation stage.- Parameters:
context- the action contextrequest- the retriever request- Returns:
- the retriever response with matching documents
-
index
Indexes documents into the collection, generating an embedding for each.- Parameters:
context- the action contextrequest- the indexer request- Returns:
- the indexer response
-