Class VectorField.VectorFieldBuilder

java.lang.Object
com.redis.vl.schema.VectorField.VectorFieldBuilder
Enclosing class:
VectorField

public static class VectorField.VectorFieldBuilder extends Object
Fluent builder for VectorField
  • Method Details

    • name

      Set the field name
      Parameters:
      name - Field name
      Returns:
      This builder
    • alias

      public VectorField.VectorFieldBuilder alias(String alias)
      Set the field alias
      Parameters:
      alias - Field alias
      Returns:
      This builder
    • withAlias

      public VectorField.VectorFieldBuilder withAlias(String alias)
      Set the field alias (alternative method)
      Parameters:
      alias - Field alias
      Returns:
      This builder
    • indexed

      public VectorField.VectorFieldBuilder indexed(boolean indexed)
      Set whether the field is indexed
      Parameters:
      indexed - True if indexed
      Returns:
      This builder
    • sortable

      public VectorField.VectorFieldBuilder sortable(boolean sortable)
      Set whether the field is sortable
      Parameters:
      sortable - True if sortable
      Returns:
      This builder
    • dimensions

      public VectorField.VectorFieldBuilder dimensions(int dimensions)
      Set the number of dimensions
      Parameters:
      dimensions - Number of dimensions in the vector
      Returns:
      This builder
    • algorithm

      Set the vector indexing algorithm
      Parameters:
      algorithm - Vector algorithm (FLAT or HNSW)
      Returns:
      This builder
    • withAlgorithm

      Set the vector indexing algorithm (alternative method)
      Parameters:
      algorithm - Vector algorithm (FLAT or HNSW)
      Returns:
      This builder
    • distanceMetric

      public VectorField.VectorFieldBuilder distanceMetric(VectorField.DistanceMetric distanceMetric)
      Set the distance metric
      Parameters:
      distanceMetric - Distance metric (L2, IP, or COSINE)
      Returns:
      This builder
    • withDistanceMetric

      public VectorField.VectorFieldBuilder withDistanceMetric(VectorField.DistanceMetric distanceMetric)
      Set the distance metric (alternative method)
      Parameters:
      distanceMetric - Distance metric (L2, IP, or COSINE)
      Returns:
      This builder
    • dataType

      Set the data type
      Parameters:
      dataType - Data type (FLOAT32 or FLOAT64)
      Returns:
      This builder
    • initialCapacity

      public VectorField.VectorFieldBuilder initialCapacity(int initialCapacity)
      Set the initial capacity for FLAT algorithm
      Parameters:
      initialCapacity - Initial capacity
      Returns:
      This builder
    • blockSize

      public VectorField.VectorFieldBuilder blockSize(int blockSize)
      Set the block size for FLAT algorithm
      Parameters:
      blockSize - Block size
      Returns:
      This builder
    • hnswM

      public VectorField.VectorFieldBuilder hnswM(int m)
      Set the M parameter for HNSW algorithm
      Parameters:
      m - M parameter
      Returns:
      This builder
    • withHnswM

      public VectorField.VectorFieldBuilder withHnswM(int m)
      Set the M parameter for HNSW algorithm (alternative method)
      Parameters:
      m - M parameter
      Returns:
      This builder
    • hnswEfConstruction

      public VectorField.VectorFieldBuilder hnswEfConstruction(int efConstruction)
      Set the EF_CONSTRUCTION parameter for HNSW algorithm
      Parameters:
      efConstruction - EF_CONSTRUCTION parameter
      Returns:
      This builder
    • withHnswEfConstruction

      public VectorField.VectorFieldBuilder withHnswEfConstruction(int efConstruction)
      Set the EF_CONSTRUCTION parameter for HNSW algorithm (alternative method)
      Parameters:
      efConstruction - EF_CONSTRUCTION parameter
      Returns:
      This builder
    • hnswEfRuntime

      public VectorField.VectorFieldBuilder hnswEfRuntime(int efRuntime)
      Set the EF_RUNTIME parameter for HNSW algorithm
      Parameters:
      efRuntime - EF_RUNTIME parameter
      Returns:
      This builder
    • epsilon

      public VectorField.VectorFieldBuilder epsilon(double epsilon)
      Set the epsilon parameter for HNSW algorithm
      Parameters:
      epsilon - Epsilon parameter
      Returns:
      This builder
    • graphMaxDegree

      public VectorField.VectorFieldBuilder graphMaxDegree(int graphMaxDegree)
      Set the graph max degree for SVS-VAMANA algorithm.

      Controls the maximum number of edges per node in the VAMANA graph. Higher values improve recall but increase memory usage and build time.

      Parameters:
      graphMaxDegree - Max edges per node (recommended: 32-64, default: 40)
      Returns:
      This builder
    • constructionWindowSize

      public VectorField.VectorFieldBuilder constructionWindowSize(int constructionWindowSize)
      Set the construction window size for SVS-VAMANA algorithm.

      Number of candidates considered during graph construction. Higher values improve index quality but increase build time.

      Parameters:
      constructionWindowSize - Build-time candidates (default: 250)
      Returns:
      This builder
    • searchWindowSize

      public VectorField.VectorFieldBuilder searchWindowSize(int searchWindowSize)
      Set the search window size for SVS-VAMANA algorithm.

      Number of candidates considered during search. This is the primary tuning parameter for accuracy vs performance trade-off. Higher values improve recall but increase query latency.

      Parameters:
      searchWindowSize - Search candidates (recommended: 20-50, default: 20)
      Returns:
      This builder
    • svsEpsilon

      public VectorField.VectorFieldBuilder svsEpsilon(double svsEpsilon)
      Set the epsilon parameter for SVS-VAMANA range queries.

      Boundary expansion factor for range queries.

      Parameters:
      svsEpsilon - Epsilon value (default: 0.01)
      Returns:
      This builder
    • compression

      Set the compression type for SVS-VAMANA algorithm.

      Available compression types:

      • LVQ4, LVQ4x4, LVQ4x8, LVQ8: Learned Vector Quantization (no dimension reduction)
      • LeanVec4x8, LeanVec8x8: Supports dimension reduction via reduce parameter
      Parameters:
      compression - Compression type
      Returns:
      This builder
    • reduce

      public VectorField.VectorFieldBuilder reduce(int reduce)
      Set the dimensionality reduction factor for LeanVec compression.

      Important: Only valid with LeanVec compression types. Must be less than the vector dimensions.

      Recommended values: dimensions/2 or dimensions/4

      Parameters:
      reduce - Target dimensions after reduction (must be < dimensions)
      Returns:
      This builder
      Throws:
      IllegalArgumentException - if used without LeanVec compression
    • trainingThreshold

      public VectorField.VectorFieldBuilder trainingThreshold(int trainingThreshold)
      Set the training threshold for SVS-VAMANA compression.

      Minimum number of vectors required before compression training begins.

      Parameters:
      trainingThreshold - Minimum vectors (default: 10,240)
      Returns:
      This builder
    • build

      public VectorField build()
      Build the VectorField
      Returns:
      VectorField instance