Struct rustis::commands::FtSearchOptions

source ·
pub struct FtSearchOptions { /* private fields */ }
Available on crate feature redis-search only.
Expand description

Options for the ft_search command.

Implementations§

source§

impl FtSearchOptions

source

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.

source

pub fn verbatim(self) -> Self

does not try to use stemming for query expansion but searches the query terms verbatim.

source

pub fn withscores(self) -> Self

also returns the relative internal score of each document.

This can be used to merge results from multiple instances.

source

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.

source

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.

source

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.

source

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.

source

pub fn inkeys<A>(self, keys: impl SingleArgCollection<A>) -> Self
where 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.

source

pub fn infields<A>(self, attributes: impl SingleArgCollection<A>) -> Self
where A: SingleArg,

filters the results to those appearing only in specific attributes of the document, like title or URL.

source

pub fn _return( self, attributes: impl MultipleArgsCollection<FtSearchReturnAttribute> ) -> Self

limits the attributes returned from the document.

If attributes is empty, it acts like nocontent.

source

pub fn summarize(self, options: FtSearchSummarizeOptions) -> Self

returns only the sections of the attribute that contain the matched text.

See Highlighting for more information.

source

pub fn highlight(self, options: FtSearchHighlightOptions) -> Self

formats occurrences of matched text.

See Highlighting for more information.

source

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.

source

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.

source

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.

source

pub fn expander(self, expander: impl SingleArg) -> Self

uses a custom query expander instead of the stemmer.

See Extensions.

source

pub fn scorer(self, scorer: impl SingleArg) -> Self

uses a custom scoring function you define.

See Extensions.

source

pub fn explainscore(self) -> Self

returns a textual description of how the scores were calculated.

Using this options requires the withscores option.

source

pub fn payload(self, payload: impl SingleArg) -> Self

adds an arbitrary, binary safe payload that is exposed to custom scoring functions.

See Extensions.

source

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.

source

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.

source

pub fn timeout(self, milliseconds: u64) -> Self

overrides the timeout parameter of the module.

source

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.

source

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.

Trait Implementations§

source§

impl Default for FtSearchOptions

source§

fn default() -> FtSearchOptions

Returns the “default value” for a type. Read more
source§

impl ToArgs for FtSearchOptions

source§

fn write_args(&self, args: &mut CommandArgs)

Write this Rust type as one ore multiple args into CommandArgs. Read more
source§

fn num_args(&self) -> usize

Number arguments generated by this Rust type

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V

source§

impl<T> MultipleArgsCollection<T> for T
where T: ToArgs,