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 class
Builder for creating VectorRangeQuery instances. -
Method Summary
Modifier and TypeMethodDescriptionstatic VectorRangeQuery.Builder
builder()
Create a new Builder for VectorRangeQuery.double
Get the distance threshold for range filtering.Get the epsilon value for approximate search.getField()
Get the field name to search.int
getK()
Deprecated.Use getNumResults() insteadint
Get the maximum number of results to return.Get the list of fields to return in results.Get the field name to sort results by.float[]
Get the query vector.boolean
Check if query terms must appear in order.boolean
Check if vector distances should be normalized.boolean
Check if scores should be returned with results.boolean
Check if results should be sorted in descending order.void
setDistanceThreshold
(double distanceThreshold) Set the distance threshold for range filtering.void
setEpsilon
(double epsilon) Set the epsilon value for approximate search.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.- Parameters:
epsilon
- Epsilon value for HNSW search
-
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
-
toQueryString
Build the query string for Redis range query- Returns:
- Query string
-
toParams
Convert to parameter map for query execution- Returns:
- Parameters map
-
toString
-