Class VectorIndexConfiguration
-
Nested Class Summary
-
Constructor Summary
ConstructorDescriptionVectorIndexConfiguration
(String expression, long dimensions, long centroids) VectorIndexConfiguration Constructor. -
Method Summary
Modifier and TypeMethodDescriptionlong
The number of centroids: the number buckets into which to partition the vectors in the index.long
The number of vector dimensions.Vector encoding type.Get the index expression.long
The max number of vectors used when training the index.Method used to measure distance between vectors.long
The minimum number of vectors for training the index.setEncoding
(VectorEncoding encoding) setMaxTrainingSize
(long maxTrainingSize) setMinTrainingSize
(long minTrainingSize) Methods inherited from class com.couchbase.lite.IndexConfiguration
getExpressions
-
Constructor Details
-
VectorIndexConfiguration
VectorIndexConfiguration Constructor.The number of centroids will be based on the expected number of vectors or documents containing the vectors to be indexed and the application may need to make some experiments to see find an optimal value to use; one simple rule which could be a starting point is to use the square root value of the number of vectors.
- Parameters:
expression
- The SQL++ expression returning a vector which is an array of numbers.dimensions
- The number of dimensions of the vectors to be indexed. Vectors that do not have the specified dimensions will not be indexed. Max dimensions must be between 2 and 2048, inclusive.centroids
- The number of centroids is the number buckets into which to partition the vectors in the index. The number of centroids will be based on the expected number of vectors to be indexed. A suggested rule is that it be the square root of the number of vectors. Max centroids must be between 1 and 64000, inclusive.
-
-
Method Details
-
getExpression
Get the index expression.- Returns:
- the index expression.
-
getDimensions
public long getDimensions()The number of vector dimensions.- Returns:
- the number of dimensions
-
getCentroids
public long getCentroids()The number of centroids: the number buckets into which to partition the vectors in the index.- Returns:
- the number of centroids
-
getEncoding
Vector encoding type.The default value is an 8-bit Scalar Quantizer.
-
setEncoding
-
getMetric
Method used to measure distance between vectors.The default value is euclidean.
-
setMetric
@NonNull public VectorIndexConfiguration setMetric(@NonNull VectorIndexConfiguration.DistanceMetric metric) -
getMinTrainingSize
public long getMinTrainingSize()The minimum number of vectors for training the index.The default value is 25 times number of centroids. The number must be more than zero and not greater than maxTrainingSize. An invalid argument exception will be thrown when creating the index if an invalid value is used.
Note: The training process is performed only once on the first query executed against the index when the number of vectors is at least minTrainingSize. When the training process is triggered the query might take longer than usual to return the result.
If a query is executed against the index before the index is trained, a full scan on the vectors will be performed for the query.
- Returns:
- the min number of vectors used in training the index
-
setMinTrainingSize
-
getMaxTrainingSize
public long getMaxTrainingSize()The max number of vectors used when training the index. The default value is 256 times number of centroids. The number must be more than zero and not less than minTrainingSize. An invalid argument exception will be thrown when creating the index if an invalid value is used.- Returns:
- the max number of vectors used in training the index
-
setMaxTrainingSize
-