Struct meilisearch_sdk::search::Query[][src]

pub struct Query<'a> {
    pub query: Option<&'a str>,
    pub offset: Option<usize>,
    pub limit: Option<usize>,
    pub filter: Option<&'a str>,
    pub facets_distribution: 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 attributes_to_highlight: Option<Selectors<&'a [&'a str]>>,
    pub matches: Option<bool>,
    // some fields omitted
}
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

let query = Query::new(&index)
    .with_query("space")
    .with_offset(42)
    .with_limit(21)
    .build(); // you can also execute() instead of build()
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_distribution: 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>

Number of characters to keep on each side of the start of the matching word. See attributes_to_crop.

Default: 200

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.

matches: Option<bool>

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

Default: false

Implementations

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

Performs the conversion.

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

Performs the conversion.

The resulting type after obtaining ownership.

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

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

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