Struct rustis::commands::FtSearchOptions
source · pub struct FtSearchOptions { /* private fields */ }
redis-search
only.Expand description
Options for the ft_search
command.
Implementations§
source§impl FtSearchOptions
impl FtSearchOptions
sourcepub fn nocontent(self) -> Self
pub fn nocontent(self) -> Self
returns the document ids and not the content. This is useful if RediSearch is only an index on an external document collection.
sourcepub fn verbatim(self) -> Self
pub fn verbatim(self) -> Self
does not try to use stemming for query expansion but searches the query terms verbatim.
sourcepub fn withscores(self) -> Self
pub fn withscores(self) -> Self
also returns the relative internal score of each document.
This can be used to merge results from multiple instances.
sourcepub fn withpayloads(self) -> Self
pub fn withpayloads(self) -> Self
retrieves optional document payloads.
See ft_create
The payloads follow the document id and, if withscores
is set, the scores.
sourcepub fn withsortkeys(self) -> Self
pub fn withsortkeys(self) -> Self
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 with sortby
.
sourcepub fn filter(
self,
numeric_field: impl SingleArg,
min: impl SingleArg,
max: impl SingleArg
) -> Self
pub fn filter( self, numeric_field: impl SingleArg, min: impl SingleArg, max: impl SingleArg ) -> Self
limits results to those having numeric values ranging between min and max,
if numeric_field is defined as a numeric field in ft_create
.
min
and max
follow zrange
syntax, and can be -inf
, +inf
,
and use (
for exclusive ranges. Multiple numeric filters for different attributes are supported in one query.
sourcepub fn geo_filter(
self,
geo_field: impl SingleArg,
lon: f64,
lat: f64,
radius: f64,
unit: GeoUnit
) -> Self
pub fn geo_filter( self, geo_field: impl SingleArg, lon: f64, lat: f64, radius: f64, unit: GeoUnit ) -> Self
filter the results to a given radius
from lon
and lat
.
radius
is given as a number and units.
See geosearch
for more details.
sourcepub fn inkeys<A>(self, keys: impl SingleArgCollection<A>) -> Selfwhere
A: SingleArg,
pub fn inkeys<A>(self, keys: impl SingleArgCollection<A>) -> Selfwhere
A: SingleArg,
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.
sourcepub fn infields<A>(self, attributes: impl SingleArgCollection<A>) -> Selfwhere
A: SingleArg,
pub fn infields<A>(self, attributes: impl SingleArgCollection<A>) -> Selfwhere
A: SingleArg,
filters the results to those appearing only in specific attributes of the document, like title
or URL
.
sourcepub fn _return(
self,
attributes: impl MultipleArgsCollection<FtSearchReturnAttribute>
) -> Self
pub fn _return( self, attributes: impl MultipleArgsCollection<FtSearchReturnAttribute> ) -> Self
limits the attributes returned from the document.
If attributes is empty, it acts like nocontent
.
sourcepub fn summarize(self, options: FtSearchSummarizeOptions) -> Self
pub fn summarize(self, options: FtSearchSummarizeOptions) -> Self
returns only the sections of the attribute that contain the matched text.
See Highlighting
for more information.
sourcepub fn highlight(self, options: FtSearchHighlightOptions) -> Self
pub fn highlight(self, options: FtSearchHighlightOptions) -> Self
formats occurrences of matched text.
See Highlighting
for more information.
sourcepub fn slop(self, slop: usize) -> Self
pub fn slop(self, slop: usize) -> Self
allows a maximum of N intervening number of unmatched offsets between phrase terms.
In other words, the slop for exact phrases is 0.
sourcepub fn inorder(self) -> Self
pub fn inorder(self) -> Self
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 with slop
.
sourcepub fn language(self, language: FtLanguage) -> Self
pub fn language(self, language: FtLanguage) -> Self
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. See FT.CREATE for the list of languages.
sourcepub fn expander(self, expander: impl SingleArg) -> Self
pub fn expander(self, expander: impl SingleArg) -> Self
uses a custom query expander
instead of the stemmer.
See Extensions
.
sourcepub fn scorer(self, scorer: impl SingleArg) -> Self
pub fn scorer(self, scorer: impl SingleArg) -> Self
uses a custom scoring function you define.
See Extensions
.
sourcepub fn explainscore(self) -> Self
pub fn explainscore(self) -> Self
returns a textual description of how the scores were calculated.
Using this options requires the withscores
option.
sourcepub fn payload(self, payload: impl SingleArg) -> Self
pub fn payload(self, payload: impl SingleArg) -> Self
adds an arbitrary, binary safe payload
that is exposed to custom scoring functions.
See Extensions
.
sourcepub fn sortby(self, attribute: impl SingleArg, order: SortOrder) -> Self
pub fn sortby(self, attribute: impl SingleArg, order: SortOrder) -> Self
orders the results by the value of this attribute.
This applies to both text and numeric attributes.
Attributes needed for sortby
should be declared as SORTABLE
in the index,
in order to be available with very low latency. Note that this adds memory overhead.
sourcepub fn limit(self, first: usize, num: usize) -> Self
pub fn limit(self, first: usize, num: usize) -> Self
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 use LIMIT 0 0
to count the number of documents in the result set without actually returning them.
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.