Package com.redis.vl.query
Class VectorRangeQuery
java.lang.Object
com.redis.vl.query.VectorRangeQuery
Vector range query for finding vectors within a distance threshold.
This class is final to prevent finalizer attacks, as it throws exceptions in constructors for input validation (SEI CERT OBJ11-J).
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classBuilder for creating VectorRangeQuery instances. -
Method Summary
Modifier and TypeMethodDescriptionstatic VectorRangeQuery.Builderbuilder()Create a new Builder for VectorRangeQuery.doubleGet the distance threshold for range filtering.Get the epsilon value for approximate search.getField()Get the field name to search.intgetK()Deprecated.Use getNumResults() insteadintGet the maximum number of results to return.Get the list of fields to return in results.Get the search buffer capacity for SVS-VAMANA algorithm.Get the search window size for SVS-VAMANA algorithm.Get the list of fields that should not be decoded from binary format.Get the field name to sort results by.Get the use search history mode for SVS-VAMANA algorithm.float[]Get the query vector.booleanCheck if query terms must appear in order.booleanCheck if vector distances should be normalized.booleanCheck if scores should be returned with results.booleanCheck if results should be sorted in descending order.voidsetDistanceThreshold(double distanceThreshold) Set the distance threshold for range filtering.voidsetEpsilon(double epsilon) Set the epsilon value for approximate search.voidsetSearchBufferCapacity(int searchBufferCapacity) Set the search buffer capacity for SVS-VAMANA algorithm.voidsetSearchWindowSize(int searchWindowSize) Set the search window size for SVS-VAMANA algorithm.voidsetUseSearchHistory(String useSearchHistory) Set the use search history mode for SVS-VAMANA algorithm.toParams()Convert to parameter map for query executionBuild the query string for Redis range querytoString()
-
Method Details
-
builder
Create a new Builder for VectorRangeQuery.- Returns:
- A new Builder instance
-
getVector
public float[] getVector()Get the query vector.- Returns:
- Copy of the query vector
-
getField
Get the field name to search.- Returns:
- Vector field name
-
getReturnFields
Get the list of fields to return in results.- Returns:
- Copy of return fields list or null
-
getDistanceThreshold
public double getDistanceThreshold()Get the distance threshold for range filtering.- Returns:
- Distance threshold value
-
setDistanceThreshold
public void setDistanceThreshold(double distanceThreshold) Set the distance threshold for range filtering.- Parameters:
distanceThreshold- New distance threshold value- Throws:
IllegalArgumentException- if threshold > 1.0 when normalizing
-
getNumResults
public int getNumResults()Get the maximum number of results to return.- Returns:
- Number of results
-
getK
Deprecated.Use getNumResults() insteadGet the maximum number of results (deprecated alias).- Returns:
- Number of results
-
isReturnScore
public boolean isReturnScore()Check if scores should be returned with results.- Returns:
- True if scores should be returned
-
isNormalizeVectorDistance
public boolean isNormalizeVectorDistance()Check if vector distances should be normalized.- Returns:
- True if normalizing distances
-
getEpsilon
Get the epsilon value for approximate search.- Returns:
- Epsilon value or null
-
setEpsilon
public void setEpsilon(double epsilon) Set the epsilon value for approximate search.Python PR #439: Runtime parameter for range query approximation. Must be non-negative.
- Parameters:
epsilon- Epsilon value for range search (must be non-negative)- Throws:
IllegalArgumentException- if epsilon is negative
-
getSearchWindowSize
Get the search window size for SVS-VAMANA algorithm.- Returns:
- Search window size or null
-
setSearchWindowSize
public void setSearchWindowSize(int searchWindowSize) Set the search window size for SVS-VAMANA algorithm.Python PR #439: SVS-VAMANA runtime parameter for KNN search window.
- Parameters:
searchWindowSize- Search window size (must be positive)- Throws:
IllegalArgumentException- if searchWindowSize is not positive
-
getUseSearchHistory
Get the use search history mode for SVS-VAMANA algorithm.- Returns:
- Use search history mode or null
-
setUseSearchHistory
Set the use search history mode for SVS-VAMANA algorithm.Python PR #439: SVS-VAMANA runtime parameter for search buffer control.
- Parameters:
useSearchHistory- Search history mode (OFF, ON, or AUTO)- Throws:
IllegalArgumentException- if not one of: OFF, ON, AUTO
-
getSearchBufferCapacity
Get the search buffer capacity for SVS-VAMANA algorithm.- Returns:
- Search buffer capacity or null
-
setSearchBufferCapacity
public void setSearchBufferCapacity(int searchBufferCapacity) Set the search buffer capacity for SVS-VAMANA algorithm.Python PR #439: SVS-VAMANA runtime parameter for compression tuning.
- Parameters:
searchBufferCapacity- Search buffer capacity (must be positive)- Throws:
IllegalArgumentException- if searchBufferCapacity is not positive
-
getSortBy
Get the field name to sort results by.- Returns:
- Sort field name or null
-
isSortDescending
public boolean isSortDescending()Check if results should be sorted in descending order.- Returns:
- True if sorting descending
-
isInOrder
public boolean isInOrder()Check if query terms must appear in order.- Returns:
- True if enforcing term order
-
getSkipDecodeFields
Get the list of fields that should not be decoded from binary format.- Returns:
- List of field names to skip decoding
-
toQueryString
Build the query string for Redis range query- Returns:
- Query string
-
toParams
Convert to parameter map for query execution- Returns:
- Parameters map
-
toString
-