Class MongoVectorStore

java.lang.Object
com.google.genkit.plugins.mongodb.MongoVectorStore

public final class MongoVectorStore extends Object
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 Details

    • MongoVectorStore

      public MongoVectorStore(com.mongodb.client.MongoClient client, MongoVectorStoreConfig config, Embedder embedder)
      Creates a new store.
      Parameters:
      client - the MongoDB client
      config - the collection configuration
      embedder - the embedder used to vectorize documents and queries
  • Method Details

    • retrieve

      public RetrieverResponse retrieve(ActionContext context, RetrieverRequest request)
      Retrieves documents similar to the query using the $vectorSearch aggregation stage.
      Parameters:
      context - the action context
      request - the retriever request
      Returns:
      the retriever response with matching documents
    • index

      public IndexerResponse index(ActionContext context, IndexerRequest request)
      Indexes documents into the collection, generating an embedding for each.
      Parameters:
      context - the action context
      request - the indexer request
      Returns:
      the indexer response