pub struct Query<'a> {
Show 14 fields pub query: Option<&'a str>, pub offset: Option<usize>, pub limit: Option<usize>, pub filter: Option<&'a str>, pub facets: Option<Selectors<&'a [&'a str]>>, pub sort: Option<&'a [&'a str]>, pub attributes_to_retrieve: Option<Selectors<&'a [&'a str]>>, pub attributes_to_crop: Option<Selectors<&'a [(&'a str, Option<usize>)]>>, pub crop_length: Option<usize>, pub crop_marker: Option<&'a str>, pub attributes_to_highlight: Option<Selectors<&'a [&'a str]>>, pub highlight_pre_tag: Option<&'a str>, pub highlight_post_tag: Option<&'a str>, pub show_matches_position: Option<bool>, /* private fields */
}
Expand description

A struct representing a query. You can add search parameters using the builder syntax. See this page for the official list and description of all parameters.

Examples

use serde::{Serialize, Deserialize};
#[derive(Serialize, Deserialize, Debug)]
struct Movie {
    name: String,
    description: String,
}


let mut res = Query::new(&index)
    .with_query("space")
    .with_offset(42)
    .with_limit(21)
    .execute::<Movie>()
    .await
    .unwrap();

assert_eq!(res.limit, 21);
let query = index.search()
    .with_query("space")
    .with_offset(42)
    .with_limit(21)
    .build(); // you can also execute() instead of build()

Fields

query: Option<&'a str>

The text that will be searched for among the documents.

offset: Option<usize>

The number of documents to skip. If the value of the parameter offset is n, the n first documents (ordered by relevance) will not be returned. This is helpful for pagination.

Example: If you want to skip the first document, set offset to 1.

limit: Option<usize>

The maximum number of documents returned. If the value of the parameter limit is n, there will never be more than n documents in the response. This is helpful for pagination.

Example: If you don’t want to get more than two documents, set limit to 2. Default: 20

filter: Option<&'a str>

Filter applied to documents. Read the dedicated guide to learn the syntax.

facets: Option<Selectors<&'a [&'a str]>>

Facets for which to retrieve the matching count.

Can be set to a wildcard value that will select all existing attributes. Default: all attributes found in the documents.

sort: Option<&'a [&'a str]>

Attributes to sort.

attributes_to_retrieve: Option<Selectors<&'a [&'a str]>>

Attributes to display in the returned documents.

Can be set to a wildcard value that will select all existing attributes. Default: all attributes found in the documents.

attributes_to_crop: Option<Selectors<&'a [(&'a str, Option<usize>)]>>

Attributes whose values have to be cropped. Attributes are composed by the attribute name and an optional usize that overwrites the crop_length parameter.

Can be set to a wildcard value that will select all existing attributes.

crop_length: Option<usize>

Maximum number of words including the matched query term(s) contained in the returned cropped value(s). See attributes_to_crop.

Default: 10

crop_marker: Option<&'a str>

Marker at the start and the end of a cropped value. ex: ...middle of a crop...

Default: ...

attributes_to_highlight: Option<Selectors<&'a [&'a str]>>

Attributes whose values will contain highlighted matching terms.

Can be set to a wildcard value that will select all existing attributes.

highlight_pre_tag: Option<&'a str>

Tag in front of a highlighted term. ex: <mytag>hello world

Default: <em>

highlight_post_tag: Option<&'a str>

Tag after the a highlighted term. ex: hello world</ mytag>

Default: </em>

show_matches_position: Option<bool>

Defines whether an object that contains information about the matches should be returned or not.

Default: false

Implementations

source

pub fn with_highlight_post_tag<'b>(
    &'b mut self,
    highlight_post_tag: &'a str
) -> &'b mut Query<'a>

Execute the query and fetch the results.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

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

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more