Struct rustis::commands::FtAggregateOptions
source · pub struct FtAggregateOptions { /* private fields */ }redis-search only.Expand description
Options for the ft_create command
Implementations§
source§impl FtAggregateOptions
impl FtAggregateOptions
sourcepub fn verbatim(self) -> Self
pub fn verbatim(self) -> Self
if set, does not try to use stemming for query expansion but searches the query terms verbatim.
Attributes needed for aggregations should be stored as SORTABLE,
where they are available to the aggregation pipeline with very low latency.
LOAD hurts the performance of aggregate queries considerably because every processed record
needs to execute the equivalent of HMGET against a Redis key,
which when executed over millions of keys, amounts to high processing times.
sourcepub fn load<A: MultipleArgsCollection<FtLoadAttribute>>(
self,
attributes: A
) -> Self
pub fn load<A: MultipleArgsCollection<FtLoadAttribute>>( self, attributes: A ) -> Self
loads document attributes from the source document.
sourcepub fn groupby<P, PP, R>(self, properties: PP, reducers: R) -> Self
pub fn groupby<P, PP, R>(self, properties: PP, reducers: R) -> Self
groups the results in the pipeline based on one or more properties.
Each group should have at least one reducer,
a function that handles the group entries,
either counting them,
or performing multiple aggregate operations (see FtReducer).
sourcepub fn sortby<P>(self, properties: P, max: Option<usize>) -> Selfwhere
P: MultipleArgsCollection<FtSortBy>,
pub fn sortby<P>(self, properties: P, max: Option<usize>) -> Selfwhere
P: MultipleArgsCollection<FtSortBy>,
Sort the pipeline up until the point of SORTBY, using a list of properties.
max is used to optimized sorting, by sorting only for the n-largest elements.
Although it is not connected to limit, you usually need just SORTBY … MAX for common queries.
sourcepub fn apply<E, N>(self, expr: E, name: N) -> Self
pub fn apply<E, N>(self, expr: E, name: N) -> Self
applies a 1-to-1 transformation on one or more properties and either stores the result as a new property down the pipeline or replaces any property using this transformation.
expr is an expression that can be used to perform arithmetic operations on numeric properties,
or functions that can be applied on properties depending on their types (see below),
or any combination thereof. For example, APPLY "sqrt(@foo)/log(@bar) + 5" AS baz
evaluates this expression dynamically for each record in the pipeline and store the result as
a new property called baz, which can be referenced by further APPLY/SORTBY/GROUPBY/REDUCE operations down the pipeline.
sourcepub fn limit(self, offset: usize, num: usize) -> Self
pub fn limit(self, offset: usize, num: usize) -> Self
Limits the number of results to return just num results starting at index offset (zero-based).
It is much more efficient to use SORTBY … MAX if you are interested in just limiting the output of a sort operation.
If a key expires during the query, an attempt to load the key’s value will return a null array.
However, limit can be used to limit results without sorting,
or for paging the n-largest results as determined by SORTBY MAX.
For example, getting results 50-100 of the top 100 results is most efficiently expressed as
SORTBY 1 @foo MAX 100 LIMIT 50 50. Removing the MAX from SORTBY results in the pipeline
sorting all the records and then paging over results 50-100.
sourcepub fn filter<E, N>(self, expr: E) -> Selfwhere
E: SingleArg,
pub fn filter<E, N>(self, expr: E) -> Selfwhere
E: SingleArg,
filters the results using predicate expressions relating to values in each result. They are applied post query and relate to the current state of the pipeline.
sourcepub fn withcursor(self, options: FtWithCursorOptions) -> Self
pub fn withcursor(self, options: FtWithCursorOptions) -> Self
Scan part of the results with a quicker alternative than limit.
See Cursor API for more details.
sourcepub fn timeout(self, milliseconds: u64) -> Self
pub fn timeout(self, milliseconds: u64) -> Self
if set, overrides the timeout parameter of the module.
sourcepub fn params<N, V, P>(self, params: P) -> Self
pub fn params<N, V, P>(self, params: P) -> Self
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[("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 or greater than 2.
sourcepub fn dialect(self, dialect_version: u64) -> Self
pub fn dialect(self, dialect_version: u64) -> Self
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 or via ft_config_set command.