Package com.redis.vl.schema
Class VectorField.VectorFieldBuilder
java.lang.Object
com.redis.vl.schema.VectorField.VectorFieldBuilder
- Enclosing class:
VectorField
Fluent builder for VectorField
-
Method Summary
Modifier and TypeMethodDescriptionalgorithm(VectorField.VectorAlgorithm algorithm) Set the vector indexing algorithmSet the field aliasblockSize(int blockSize) Set the block size for FLAT algorithmbuild()Build the VectorFieldcompression(VectorField.CompressionType compression) Set the compression type for SVS-VAMANA algorithm.constructionWindowSize(int constructionWindowSize) Set the construction window size for SVS-VAMANA algorithm.dataType(VectorField.VectorDataType dataType) Set the data typedimensions(int dimensions) Set the number of dimensionsdistanceMetric(VectorField.DistanceMetric distanceMetric) Set the distance metricepsilon(double epsilon) Set the epsilon parameter for HNSW algorithmgraphMaxDegree(int graphMaxDegree) Set the graph max degree for SVS-VAMANA algorithm.hnswEfConstruction(int efConstruction) Set the EF_CONSTRUCTION parameter for HNSW algorithmhnswEfRuntime(int efRuntime) Set the EF_RUNTIME parameter for HNSW algorithmhnswM(int m) Set the M parameter for HNSW algorithmindexed(boolean indexed) Set whether the field is indexedinitialCapacity(int initialCapacity) Set the initial capacity for FLAT algorithmSet the field namereduce(int reduce) Set the dimensionality reduction factor for LeanVec compression.searchWindowSize(int searchWindowSize) Set the search window size for SVS-VAMANA algorithm.sortable(boolean sortable) Set whether the field is sortablesvsEpsilon(double svsEpsilon) Set the epsilon parameter for SVS-VAMANA range queries.trainingThreshold(int trainingThreshold) Set the training threshold for SVS-VAMANA compression.withAlgorithm(VectorField.VectorAlgorithm algorithm) Set the vector indexing algorithm (alternative method)Set the field alias (alternative method)withDistanceMetric(VectorField.DistanceMetric distanceMetric) Set the distance metric (alternative method)withHnswEfConstruction(int efConstruction) Set the EF_CONSTRUCTION parameter for HNSW algorithm (alternative method)withHnswM(int m) Set the M parameter for HNSW algorithm (alternative method)
-
Method Details
-
name
Set the field name- Parameters:
name- Field name- Returns:
- This builder
-
alias
Set the field alias- Parameters:
alias- Field alias- Returns:
- This builder
-
withAlias
Set the field alias (alternative method)- Parameters:
alias- Field alias- Returns:
- This builder
-
indexed
Set whether the field is indexed- Parameters:
indexed- True if indexed- Returns:
- This builder
-
sortable
Set whether the field is sortable- Parameters:
sortable- True if sortable- Returns:
- This builder
-
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
Set the distance metric- Parameters:
distanceMetric- Distance metric (L2, IP, or COSINE)- Returns:
- This builder
-
withDistanceMetric
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
Set the initial capacity for FLAT algorithm- Parameters:
initialCapacity- Initial capacity- Returns:
- This builder
-
blockSize
Set the block size for FLAT algorithm- Parameters:
blockSize- Block size- Returns:
- This builder
-
hnswM
Set the M parameter for HNSW algorithm- Parameters:
m- M parameter- Returns:
- This builder
-
withHnswM
Set the M parameter for HNSW algorithm (alternative method)- Parameters:
m- M parameter- Returns:
- This builder
-
hnswEfConstruction
Set the EF_CONSTRUCTION parameter for HNSW algorithm- Parameters:
efConstruction- EF_CONSTRUCTION parameter- Returns:
- This builder
-
withHnswEfConstruction
Set the EF_CONSTRUCTION parameter for HNSW algorithm (alternative method)- Parameters:
efConstruction- EF_CONSTRUCTION parameter- Returns:
- This builder
-
hnswEfRuntime
Set the EF_RUNTIME parameter for HNSW algorithm- Parameters:
efRuntime- EF_RUNTIME parameter- Returns:
- This builder
-
epsilon
Set the epsilon parameter for HNSW algorithm- Parameters:
epsilon- Epsilon parameter- Returns:
- This builder
-
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
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
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
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
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
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
Build the VectorField- Returns:
- VectorField instance
-