Package com.redis.vl.query
Class FilterQuery.FilterQueryBuilder
java.lang.Object
com.redis.vl.query.FilterQuery.FilterQueryBuilder
- Enclosing class:
FilterQuery
Builder for FilterQuery with defensive copying.
-
Method Summary
Modifier and TypeMethodDescriptionbuild()Build the FilterQuery instance.dialect(int dialect) Set the query dialect.filterExpression(Filter filterExpression) Set the filter expression.inOrder(boolean inOrder) Set whether to require in-order term matching.numResults(int numResults) Set the number of results to return.Set query parameters.returnFields(List<String> returnFields) Set return fields.skipDecodeFields(String... fields) Set fields that should not be decoded from binary format (varargs).skipDecodeFields(List<String> skipDecodeFields) Set fields that should not be decoded from binary format.sortAscending(boolean ascending) Set whether to sort in ascending or descending order.Set the field to sort results by using SortField.Set the field to sort results by (defaults to ascending).Set the field to sort results by with explicit direction.Set the fields to sort results by (supports multiple fields, but only first is used).
-
Method Details
-
filterExpression
Set the filter expression.- Parameters:
filterExpression- The filter to apply- Returns:
- this builder
-
returnFields
Set return fields. Makes a defensive copy.- Parameters:
returnFields- List of field names- Returns:
- this builder
-
numResults
Set the number of results to return.- Parameters:
numResults- Maximum number of results- Returns:
- this builder
-
dialect
Set the query dialect.- Parameters:
dialect- RediSearch dialect version- Returns:
- this builder
-
sortBy
Set the field to sort results by (defaults to ascending).Python equivalent: sort_by="price"
- Parameters:
sortBy- Field name to sort by- Returns:
- this builder
-
sortBy
Set the field to sort results by with explicit direction.Python equivalent: sort_by=("price", "DESC")
- Parameters:
field- Field name to sort bydirection- Sort direction ("ASC" or "DESC", case-insensitive)- Returns:
- this builder
- Throws:
IllegalArgumentException- if direction is invalid
-
sortBy
Set the field to sort results by using SortField.Python equivalent: sort_by=("rating", "DESC") or using SortField.desc("rating")
- Parameters:
sortField- SortField specifying field and direction- Returns:
- this builder
- Throws:
IllegalArgumentException- if sortField is null
-
sortBy
Set the fields to sort results by (supports multiple fields, but only first is used).Python equivalent: sort_by=[("price", "DESC"), ("rating", "ASC"), "stock"]
Note: Redis Search only supports single-field sorting. When multiple fields are provided, only the first field is used and a warning is logged.
- Parameters:
sortFields- List of SortFields- Returns:
- this builder
-
sortAscending
Set whether to sort in ascending or descending order. Python: query.sort_by(field, asc=True/False)- Parameters:
ascending- true for ascending, false for descending- Returns:
- this builder
-
inOrder
Set whether to require in-order term matching.- Parameters:
inOrder- true to require terms in same order as query- Returns:
- this builder
-
params
Set query parameters. Makes a defensive copy.- Parameters:
params- Parameter map- Returns:
- this builder
-
skipDecodeFields
Set fields that should not be decoded from binary format.Python equivalent: skip_decode parameter in return_fields() (PR #389)
- Parameters:
skipDecodeFields- List of field names- Returns:
- this builder
- Throws:
IllegalArgumentException- if list contains null values
-
skipDecodeFields
Set fields that should not be decoded from binary format (varargs).- Parameters:
fields- Field names- Returns:
- this builder
- Throws:
IllegalArgumentException- if any field is null
-
build
Build the FilterQuery instance.- Returns:
- A new FilterQuery with the configured parameters
-