Class FirestoreRetrieverConfig.Builder

java.lang.Object
com.google.genkit.plugins.firebase.retriever.FirestoreRetrieverConfig.Builder
Enclosing class:
FirestoreRetrieverConfig

public static class FirestoreRetrieverConfig.Builder extends Object
Builder for FirestoreRetrieverConfig.
  • 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

      public FirestoreRetrieverConfig.Builder collection(String collection)
      Sets the Firestore collection name.
      Parameters:
      collection - the collection name
      Returns:
      this builder
    • vectorField

      public FirestoreRetrieverConfig.Builder vectorField(String vectorField)
      Sets the field name containing vector embeddings.
      Parameters:
      vectorField - the vector field name
      Returns:
      this builder
    • contentField

      public FirestoreRetrieverConfig.Builder contentField(String 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

      Sets the distance measure for vector similarity.
      Parameters:
      distanceMeasure - the distance measure
      Returns:
      this builder
    • distanceThreshold

      public FirestoreRetrieverConfig.Builder distanceThreshold(Double distanceThreshold)
      Sets the distance threshold for filtering results.
      Parameters:
      distanceThreshold - the distance threshold
      Returns:
      this builder
    • distanceResultField

      public FirestoreRetrieverConfig.Builder distanceResultField(String distanceResultField)
      Sets the field name to store the distance in result metadata.
      Parameters:
      distanceResultField - the distance result field name
      Returns:
      this builder
    • embedder

      public FirestoreRetrieverConfig.Builder embedder(Embedder embedder)
      Sets the embedder instance to use.
      Parameters:
      embedder - the embedder
      Returns:
      this builder
    • embedderName

      public FirestoreRetrieverConfig.Builder embedderName(String embedderName)
      Sets the embedder name for resolution from registry.
      Parameters:
      embedderName - the embedder name (e.g., "googleai/text-embedding-004")
      Returns:
      this builder
    • metadataFields

      public FirestoreRetrieverConfig.Builder metadataFields(List<String> 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

      public FirestoreRetrieverConfig.Builder defaultLimit(int 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

      public FirestoreRetrieverConfig.Builder databaseId(String 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

      public FirestoreRetrieverConfig.Builder embedderDimension(int 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

      public FirestoreRetrieverConfig build()
      Builds the configuration.
      Returns:
      the configured FirestoreRetrieverConfig
      Throws:
      IllegalStateException - if required fields are missing