Class FirestoreRetrieverConfig.Builder
java.lang.Object
com.google.genkit.plugins.firebase.retriever.FirestoreRetrieverConfig.Builder
- Enclosing class:
FirestoreRetrieverConfig
Builder for FirestoreRetrieverConfig.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuild()Builds the configuration.collection(String collection) Sets the Firestore collection name.contentExtractor(Function<com.google.cloud.firestore.QueryDocumentSnapshot, List<Part>> contentExtractor) Sets a custom content extractor function.contentField(String contentField) Sets the field name containing document content.createDatabaseIfNotExists(boolean createDatabaseIfNotExists) Sets whether to create the Firestore database if it doesn't exist.createVectorIndexIfNotExists(boolean createVectorIndexIfNotExists) Sets whether to create the Firestore vector index if it doesn't exist.databaseId(String databaseId) Sets the Firestore database ID to use.defaultLimit(int defaultLimit) Sets the default limit for retrieval results.distanceMeasure(FirestoreRetrieverConfig.DistanceMeasure distanceMeasure) Sets the distance measure for vector similarity.distanceResultField(String distanceResultField) Sets the field name to store the distance in result metadata.distanceThreshold(Double distanceThreshold) Sets the distance threshold for filtering results.Sets the embedder instance to use.embedderDimension(int embedderDimension) Sets the dimension of the embeddings for vector index creation.embedderName(String embedderName) Sets the embedder name for resolution from registry.Sets the display label for the Developer UI.metadataExtractor(Function<com.google.cloud.firestore.QueryDocumentSnapshot, Map<String, Object>> metadataExtractor) Sets a custom metadata extractor function.metadataFields(List<String> metadataFields) Sets the metadata fields to include in results.Sets the name of the retriever (required).vectorField(String vectorField) Sets the field name containing vector embeddings.
-
Constructor Details
-
Builder
public Builder()
-
-
Method Details
-
name
Sets the name of the retriever (required).- Parameters:
name- the retriever name- Returns:
- this builder
-
label
Sets the display label for the Developer UI.- Parameters:
label- the display label- Returns:
- this builder
-
collection
Sets the Firestore collection name.- Parameters:
collection- the collection name- Returns:
- this builder
-
vectorField
Sets the field name containing vector embeddings.- Parameters:
vectorField- the vector field name- Returns:
- this builder
-
contentField
Sets the field name containing document content.- Parameters:
contentField- the content field name- Returns:
- this builder
-
contentExtractor
public FirestoreRetrieverConfig.Builder contentExtractor(Function<com.google.cloud.firestore.QueryDocumentSnapshot, List<Part>> contentExtractor) Sets a custom content extractor function.- Parameters:
contentExtractor- the content extractor function- Returns:
- this builder
-
distanceMeasure
public FirestoreRetrieverConfig.Builder distanceMeasure(FirestoreRetrieverConfig.DistanceMeasure distanceMeasure) Sets the distance measure for vector similarity.- Parameters:
distanceMeasure- the distance measure- Returns:
- this builder
-
distanceThreshold
Sets the distance threshold for filtering results.- Parameters:
distanceThreshold- the distance threshold- Returns:
- this builder
-
distanceResultField
Sets the field name to store the distance in result metadata.- Parameters:
distanceResultField- the distance result field name- Returns:
- this builder
-
embedder
Sets the embedder instance to use.- Parameters:
embedder- the embedder- Returns:
- this builder
-
embedderName
Sets the embedder name for resolution from registry.- Parameters:
embedderName- the embedder name (e.g., "googleai/text-embedding-004")- Returns:
- this builder
-
metadataFields
Sets the metadata fields to include in results.- Parameters:
metadataFields- the list of metadata field names- Returns:
- this builder
-
metadataExtractor
public FirestoreRetrieverConfig.Builder metadataExtractor(Function<com.google.cloud.firestore.QueryDocumentSnapshot, Map<String, Object>> metadataExtractor) Sets a custom metadata extractor function.- Parameters:
metadataExtractor- the metadata extractor function- Returns:
- this builder
-
defaultLimit
Sets the default limit for retrieval results.- Parameters:
defaultLimit- the default limit- Returns:
- this builder
-
createDatabaseIfNotExists
public FirestoreRetrieverConfig.Builder createDatabaseIfNotExists(boolean createDatabaseIfNotExists) Sets whether to create the Firestore database if it doesn't exist.When enabled, the plugin will automatically create the database on first use if it doesn't exist. If the database already exists, this flag has no effect.
- Parameters:
createDatabaseIfNotExists- true to create database automatically- Returns:
- this builder
-
databaseId
Sets the Firestore database ID to use.Defaults to "(default)" if not specified.
- Parameters:
databaseId- the database ID- Returns:
- this builder
-
createVectorIndexIfNotExists
public FirestoreRetrieverConfig.Builder createVectorIndexIfNotExists(boolean createVectorIndexIfNotExists) Sets whether to create the Firestore vector index if it doesn't exist.When enabled, the plugin will automatically create the vector index on the configured collection and vector field if it doesn't exist. This uses a flat index type suitable for smaller collections.
- Parameters:
createVectorIndexIfNotExists- true to create vector index automatically- Returns:
- this builder
-
embedderDimension
Sets the dimension of the embeddings for vector index creation.This should match the output dimension of your embedder. Common values: 768 (text-embedding-004), 1536 (OpenAI ada-002). Defaults to 768 if not specified.
- Parameters:
embedderDimension- the embedding dimension- Returns:
- this builder
-
build
Builds the configuration.- Returns:
- the configured FirestoreRetrieverConfig
- Throws:
IllegalStateException- if required fields are missing
-