Class VectorRangeQuery

java.lang.Object
com.redis.vl.query.VectorRangeQuery

public final class VectorRangeQuery extends Object
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).

  • Method Details

    • builder

      public static VectorRangeQuery.Builder 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

      public String getField()
      Get the field name to search.
      Returns:
      Vector field name
    • getReturnFields

      public List<String> 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 public int getK()
      Deprecated.
      Use getNumResults() instead
      Get 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

      public Double 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

      public String 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

      public String toQueryString()
      Build the query string for Redis range query
      Returns:
      Query string
    • toParams

      public Map<String,Object> toParams()
      Convert to parameter map for query execution
      Returns:
      Parameters map
    • toString

      public String toString()
      Overrides:
      toString in class Object