Class QueryArgs
- java.lang.Object
-
- io.quarkus.redis.datasource.search.QueryArgs
-
- All Implemented Interfaces:
RedisCommandExtraArguments
public class QueryArgs extends Object implements RedisCommandExtraArguments
Represents the extra arguments of theft.search
command
-
-
Field Summary
Fields Modifier and Type Field Description boolean
nocontent
-
Constructor Summary
Constructors Constructor Description QueryArgs()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
containsPayload()
boolean
containsScore()
boolean
containsSortKeys()
QueryArgs
dialect(int version)
Selects the dialect version under which to execute the query.QueryArgs
expander(String expander)
Uses a custom query expander instead of the stemmer.QueryArgs
explainScore()
Returns a textual description of how the scores were calculated.QueryArgs
filter(NumericFilter filter)
Limits results to those having numeric values ranging between min and max, ifnumberFilter
is defined as a numeric attribute inFT.CREATE
.QueryArgs
geoFilter(GeoFilter filter)
Filters the results to a given radius from lon and lat.QueryArgs
highlight(HighlightArgs args)
formats occurrences of matched text.QueryArgs
inFields(String... fields)
Filters the results to those appearing only in specific attributes of the document, like title or URL.QueryArgs
inKeys(String... keys)
Limits the result to a given set of keys specified in the list.QueryArgs
inOrder()
Puts the query terms in the same order in the document as in the query, regardless of the offsets between them.QueryArgs
language(String lang)
Use a stemmer for the supplied language during search for query expansion.QueryArgs
limit(int offset, int count)
Limits the results to the offset and number of results given.QueryArgs
nocontent()
Returns the document ids and not the content.QueryArgs
param(String name, String value)
Defines one or more value parameters.QueryArgs
returnAttribute(String field)
Limits the attributes returned from the document.QueryArgs
returnAttribute(String field, String alias)
Limits the attributes returned from the document.QueryArgs
scorer(String scorer)
Uses a custom scoring function you defineQueryArgs
slop(int slop)
Allows a maximum ofslop
intervening number of unmatched offsets between phrase terms.QueryArgs
sortByAscending(String field)
Orders the results by the value of this attribute.QueryArgs
sortByDescending(String field)
Orders the results by the value of this attribute.QueryArgs
summarize(SummarizeArgs args)
Returns only the sections of the attribute that contain the matched text.QueryArgs
timeout(Duration timeout)
Overrides the timeout parameter of the module.<T> List<String>
toArgs(Codec<T> encoder)
QueryArgs
verbatim()
Does not try to use stemming for query expansion but searches the query terms verbatim.QueryArgs
withPayloads()
Retrieves optional document payloads.QueryArgs
withScores()
Also returns the relative internal score of each document.QueryArgs
withSortKeys()
returns the value of the sorting key, right after the id and score and/or payload, if requested.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface io.quarkus.redis.datasource.RedisCommandExtraArguments
toArgs
-
-
-
-
Method Detail
-
nocontent
public QueryArgs nocontent()
Returns the document ids and not the content. This is useful if RedisSearch is only an index on an external document collection.- Returns:
- the current
QueryArgs
-
verbatim
public QueryArgs verbatim()
Does not try to use stemming for query expansion but searches the query terms verbatim.- Returns:
- the current
QueryArgs
-
withScores
public QueryArgs withScores()
Also returns the relative internal score of each document. This can be used to merge results from multiple instances.- Returns:
- the current
QueryArgs
-
withPayloads
public QueryArgs withPayloads()
Retrieves optional document payloads.- Returns:
- the current
QueryArgs
-
withSortKeys
public QueryArgs withSortKeys()
returns the value of the sorting key, right after the id and score and/or payload, if requested. This is usually not needed, and exists for distributed search coordination purposes. This option is relevant only if used in conjunction withSORTBY
.- Returns:
- the current
QueryArgs
-
filter
public QueryArgs filter(NumericFilter filter)
Limits results to those having numeric values ranging between min and max, ifnumberFilter
is defined as a numeric attribute inFT.CREATE
. Min and max followZRANGE
syntax, and can be-inf
,+inf
, and use ( for exclusive ranges. Multiple numeric filters for different attributes are supported in one query.- Parameters:
filter
- the filter- Returns:
- the current
QueryArgs
-
geoFilter
public QueryArgs geoFilter(GeoFilter filter)
Filters the results to a given radius from lon and lat. Radius is given as a number and units. SeeGEORADIUS
for more details.- Parameters:
filter
- the filter- Returns:
- the current
QueryArgs
-
inKeys
public final QueryArgs inKeys(String... keys)
Limits the result to a given set of keys specified in the list. Non-existent keys are ignored, unless all the keys are non-existent.- Parameters:
keys
- the list of keys- Returns:
- the current
QueryArgs
-
inFields
public QueryArgs inFields(String... fields)
Filters the results to those appearing only in specific attributes of the document, like title or URL.- Parameters:
fields
- the list of fields- Returns:
- the current
QueryArgs
-
returnAttribute
public QueryArgs returnAttribute(String field, String alias)
Limits the attributes returned from the document. If no return clauses are passed, it acts likeNOCONTENT
.field
is either an attribute name (for hashes and JSON) or a JSON Path expression (for JSON).alias
is the optional name used in the result. If not provided, thefield
is used in the result.- Parameters:
field
- the fieldalias
- the alias- Returns:
- the current
QueryArgs
-
returnAttribute
public QueryArgs returnAttribute(String field)
Limits the attributes returned from the document. If no return clauses are passed, it acts likeNOCONTENT
.field
is either an attribute name (for hashes and JSON) or a JSON Path expression (for JSON).alias
is the name used in the result. As it is not provided, thefield
is used in the result.- Parameters:
field
- the field- Returns:
- the current
QueryArgs
-
summarize
public QueryArgs summarize(SummarizeArgs args)
Returns only the sections of the attribute that contain the matched text.- Parameters:
args
- the summarize argument- Returns:
- the current
QueryArgs
-
highlight
public QueryArgs highlight(HighlightArgs args)
formats occurrences of matched text.- Parameters:
args
- the summarize argument- Returns:
- the current
QueryArgs
-
slop
public QueryArgs slop(int slop)
Allows a maximum ofslop
intervening number of unmatched offsets between phrase terms. In other words, the slop for exact phrases is 0.- Parameters:
slop
- the slop- Returns:
- the current
QueryArgs
-
inOrder
public QueryArgs inOrder()
Puts the query terms in the same order in the document as in the query, regardless of the offsets between them. Typically used in conjunction withSLOP
.- Returns:
- the current
QueryArgs
-
language
public QueryArgs language(String lang)
Use a stemmer for the supplied language during search for query expansion. If querying documents in Chinese, set to chinese to properly tokenize the query terms. Defaults to English. If an unsupported language is sent, the command returns an error.- Parameters:
lang
- the language- Returns:
- the current
QueryArgs
-
expander
public QueryArgs expander(String expander)
Uses a custom query expander instead of the stemmer.- Parameters:
expander
- the expander- Returns:
- the current
QueryArgs
-
scorer
public QueryArgs scorer(String scorer)
Uses a custom scoring function you define- Parameters:
scorer
- the scorer- Returns:
- the current
QueryArgs
-
explainScore
public QueryArgs explainScore()
Returns a textual description of how the scores were calculated. Using this options requires thesCORES
option.- Returns:
- the current
QueryArgs
-
sortByAscending
public QueryArgs sortByAscending(String field)
Orders the results by the value of this attribute. Use ascending order. This applies to both text and numeric attributes. Attributes needed forSORTBY
should be declared asSORTABLE
in the index, in order to be available with very low latency. Note that this adds memory overhead.- Parameters:
field
- the field- Returns:
- the current
QueryArgs
-
sortByDescending
public QueryArgs sortByDescending(String field)
Orders the results by the value of this attribute. Use descending order. This applies to both text and numeric attributes. Attributes needed forSORTBY
should be declared asSORTABLE
in the index, in order to be available with very low latency. Note that this adds memory overhead.- Parameters:
field
- the field- Returns:
- the current
QueryArgs
-
limit
public QueryArgs limit(int offset, int count)
Limits the results to the offset and number of results given. Note that the offset is zero-indexed. The default is 0 10, which returns 10 items starting from the first result. You can useLIMIT 0 0
to count the number of documents in the result set without actually returning them.- Parameters:
offset
- the offsetcount
- the count- Returns:
- the current
QueryArgs
-
timeout
public QueryArgs timeout(Duration timeout)
Overrides the timeout parameter of the module.- Parameters:
timeout
- the timeout- Returns:
- the current
QueryArgs
-
param
public QueryArgs param(String name, String value)
Defines one or more value parameters. Each parameter has a name and a value. You can reference parameters in the query by a $, followed by the parameter name, for example, $user. Each such reference in the search query to a parameter name is substituted by the corresponding parameter value. For example, with parameter definition PARAMS 4 lon 29.69465 lat 34.95126, the expression @loc:[$lon $lat 10 km] is evaluated to @loc:[29.69465 34.95126 10 km]. You cannot reference parameters in the query string where concrete values are not allowed, such as in field names, for example, @loc.To use PARAMS, set DIALECT to 2.
- Parameters:
name
- the parameter namevalue
- the parameter value as String- Returns:
- the current
QueryArgs
-
dialect
public QueryArgs dialect(int version)
Selects the dialect version under which to execute the query. If not specified, the query will execute under the default dialect version set during module initial loading.- Parameters:
version
- the version- Returns:
- the current
QueryArgs
-
toArgs
public <T> List<String> toArgs(Codec<T> encoder)
- Specified by:
toArgs
in interfaceRedisCommandExtraArguments
- Parameters:
encoder
- an optional encoder to encode some of the values- Returns:
- the list of arguments, encoded as a list of String.
-
containsScore
public boolean containsScore()
-
containsPayload
public boolean containsPayload()
-
containsSortKeys
public boolean containsSortKeys()
-
-