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.searchcommand
-
-
Field Summary
Fields Modifier and Type Field Description booleannocontent
-
Constructor Summary
Constructors Constructor Description QueryArgs()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancontainsPayload()booleancontainsScore()booleancontainsSortKeys()QueryArgsdialect(int version)Selects the dialect version under which to execute the query.QueryArgsexpander(String expander)Uses a custom query expander instead of the stemmer.QueryArgsexplainScore()Returns a textual description of how the scores were calculated.QueryArgsfilter(NumericFilter filter)Limits results to those having numeric values ranging between min and max, ifnumberFilteris defined as a numeric attribute inFT.CREATE.QueryArgsgeoFilter(GeoFilter filter)Filters the results to a given radius from lon and lat.QueryArgshighlight(HighlightArgs args)formats occurrences of matched text.QueryArgsinFields(String... fields)Filters the results to those appearing only in specific attributes of the document, like title or URL.QueryArgsinKeys(String... keys)Limits the result to a given set of keys specified in the list.QueryArgsinOrder()Puts the query terms in the same order in the document as in the query, regardless of the offsets between them.QueryArgslanguage(String lang)Use a stemmer for the supplied language during search for query expansion.QueryArgslimit(int offset, int count)Limits the results to the offset and number of results given.QueryArgsnocontent()Returns the document ids and not the content.QueryArgsparam(String name, String value)Defines one or more value parameters.QueryArgsreturnAttribute(String field)Limits the attributes returned from the document.QueryArgsreturnAttribute(String field, String alias)Limits the attributes returned from the document.QueryArgsscorer(String scorer)Uses a custom scoring function you defineQueryArgsslop(int slop)Allows a maximum ofslopintervening number of unmatched offsets between phrase terms.QueryArgssortByAscending(String field)Orders the results by the value of this attribute.QueryArgssortByDescending(String field)Orders the results by the value of this attribute.QueryArgssummarize(SummarizeArgs args)Returns only the sections of the attribute that contain the matched text.QueryArgstimeout(Duration timeout)Overrides the timeout parameter of the module.List<String>toArgs(Codec encoder)QueryArgsverbatim()Does not try to use stemming for query expansion but searches the query terms verbatim.QueryArgswithPayloads()Retrieves optional document payloads.QueryArgswithScores()Also returns the relative internal score of each document.QueryArgswithSortKeys()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, ifnumberFilteris defined as a numeric attribute inFT.CREATE. Min and max followZRANGEsyntax, 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. SeeGEORADIUSfor 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.fieldis either an attribute name (for hashes and JSON) or a JSON Path expression (for JSON).aliasis the optional name used in the result. If not provided, thefieldis 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.fieldis either an attribute name (for hashes and JSON) or a JSON Path expression (for JSON).aliasis the name used in the result. As it is not provided, thefieldis 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 ofslopintervening 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 thesCORESoption.- 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 forSORTBYshould be declared asSORTABLEin 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 forSORTBYshould be declared asSORTABLEin 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 0to 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 List<String> toArgs(Codec encoder)
- Specified by:
toArgsin 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()
-
-