Class IndexSchema.Builder

java.lang.Object
com.redis.vl.schema.IndexSchema.Builder
Enclosing class:
IndexSchema

public static class IndexSchema.Builder extends Object
Builder for IndexSchema
  • Method Details

    • name

      public IndexSchema.Builder name(String name)
      Set the index name
      Parameters:
      name - the index name
      Returns:
      this builder
    • prefix

      public IndexSchema.Builder prefix(String prefix)
      Set the key prefix (single prefix)
      Parameters:
      prefix - the key prefix
      Returns:
      this builder
    • prefix

      public IndexSchema.Builder prefix(List<String> prefixes)
      Set multiple key prefixes.

      Normalizes single-element lists to strings for backward compatibility. Python port: matches behavior in convert_index_info_to_schema.

      Parameters:
      prefixes - the list of key prefixes
      Returns:
      this builder
    • withPrefix

      public IndexSchema.Builder withPrefix(String prefix)
      Set the key prefix (alias for prefix)
      Parameters:
      prefix - the key prefix
      Returns:
      this builder
    • storageType

      public IndexSchema.Builder storageType(IndexSchema.StorageType storageType)
      Set the storage type
      Parameters:
      storageType - the storage type
      Returns:
      this builder
    • withStorageType

      public IndexSchema.Builder withStorageType(IndexSchema.StorageType storageType)
      Set the storage type (alias for storageType)
      Parameters:
      storageType - the storage type
      Returns:
      this builder
    • stopwords

      public IndexSchema.Builder stopwords(List<String> stopwords)
      Set the stopwords configuration.

      Pass null to use Redis default stopwords, empty list to disable stopwords entirely (STOPWORDS 0), or a custom list of stopwords.

      Port of redis-vl-python PR #436: Index-level stopwords support

      Parameters:
      stopwords - the stopwords configuration
      Returns:
      this builder
    • noStopwords

      public IndexSchema.Builder noStopwords()
      Disable stopwords entirely (equivalent to stopwords(Collections.emptyList())).

      When stopwords are disabled, all words including common terms are indexed and searchable.

      Returns:
      this builder
    • field

      public IndexSchema.Builder field(BaseField field)
      Add a field to the schema
      Parameters:
      field - the field to add
      Returns:
      this builder
    • addTextField

      public IndexSchema.Builder addTextField(String name, Consumer<TextField.TextFieldBuilder> customizer)
      Add a text field with customization
      Parameters:
      name - the field name
      customizer - consumer to customize the field builder
      Returns:
      this builder
    • addTagField

      public IndexSchema.Builder addTagField(String name, Consumer<TagField.TagFieldBuilder> customizer)
      Add a tag field with customization
      Parameters:
      name - the field name
      customizer - consumer to customize the field builder
      Returns:
      this builder
    • addNumericField

      public IndexSchema.Builder addNumericField(String name, Consumer<NumericField.NumericFieldBuilder> customizer)
      Add a numeric field with customization
      Parameters:
      name - the field name
      customizer - consumer to customize the field builder
      Returns:
      this builder
    • addVectorField

      public IndexSchema.Builder addVectorField(String name, int dimensions, Consumer<VectorField.VectorFieldBuilder> customizer)
      Add a vector field with customization
      Parameters:
      name - the field name
      dimensions - the vector dimensions
      customizer - consumer to customize the field builder
      Returns:
      this builder
    • build

      public IndexSchema build()
      Build the IndexSchema
      Returns:
      the constructed IndexSchema
    • index

      public IndexSchema.Builder index(IndexSchema.Index index)
      Set the builder from an Index configuration
      Parameters:
      index - the Index configuration to use
      Returns:
      this builder