Class FirestoreVectorStore
java.lang.Object
com.google.genkit.plugins.firebase.retriever.FirestoreVectorStore
Firestore vector store implementation for RAG workflows.
Provides vector similarity search using Cloud Firestore's native vector search capabilities. Supports COSINE, EUCLIDEAN, and DOT_PRODUCT distance measures.
Example usage:
// Retrieve documents
RetrieverResponse response = genkit.retrieve("firebase/my-docs", Document.fromText("What is the meaning of life?"),
Map.of("limit", 5));
// Index documents
genkit.index("firebase/my-docs",
List.of(Document.fromText("The meaning of life is 42"), Document.fromText("Life is what you make of it")));
-
Constructor Summary
ConstructorsConstructorDescriptionFirestoreVectorStore(com.google.cloud.firestore.Firestore firestore, FirestoreRetrieverConfig config, Embedder embedder) Creates a new FirestoreVectorStore.FirestoreVectorStore(com.google.cloud.firestore.Firestore firestore, FirestoreRetrieverConfig config, Embedder embedder, String projectId) Creates a new FirestoreVectorStore with explicit project ID. -
Method Summary
Modifier and TypeMethodDescriptionCreates an Indexer action for this vector store.Creates a Retriever action for this vector store.voidEnsures the Firestore database exists, creating it if configured to do so.voidEnsures the Firestore vector index exists, creating it if configured to do so.index(ActionContext ctx, IndexerRequest request) Indexes documents into Firestore with their embeddings.retrieve(ActionContext ctx, RetrieverRequest request) Retrieves documents from Firestore using vector similarity search.
-
Constructor Details
-
FirestoreVectorStore
public FirestoreVectorStore(com.google.cloud.firestore.Firestore firestore, FirestoreRetrieverConfig config, Embedder embedder) Creates a new FirestoreVectorStore.- Parameters:
firestore- the Firestore instanceconfig- the retriever configurationembedder- the embedder to use
-
FirestoreVectorStore
public FirestoreVectorStore(com.google.cloud.firestore.Firestore firestore, FirestoreRetrieverConfig config, Embedder embedder, String projectId) Creates a new FirestoreVectorStore with explicit project ID.- Parameters:
firestore- the Firestore instanceconfig- the retriever configurationembedder- the embedder to useprojectId- the Google Cloud project ID
-
-
Method Details
-
ensureDatabaseExists
Ensures the Firestore database exists, creating it if configured to do so.- Throws:
GenkitException- if database creation fails
-
ensureVectorIndexExists
Ensures the Firestore vector index exists, creating it if configured to do so.- Throws:
GenkitException- if index creation fails
-
createRetriever
Creates a Retriever action for this vector store.- Returns:
- the Retriever action
-
createIndexer
Creates an Indexer action for this vector store.- Returns:
- the Indexer action
-
retrieve
public RetrieverResponse retrieve(ActionContext ctx, RetrieverRequest request) throws GenkitException Retrieves documents from Firestore using vector similarity search.- Parameters:
ctx- the action contextrequest- the retriever request- Returns:
- the retriever response with matched documents
- Throws:
GenkitException- if retrieval fails
-
index
Indexes documents into Firestore with their embeddings.- Parameters:
ctx- the action contextrequest- the indexer request- Returns:
- the indexer response
- Throws:
GenkitException- if indexing fails
-