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

pub struct Query<'a> {
    pub query: Option<&'a str>,
    pub offset: Option<usize>,
    pub limit: Option<usize>,
    pub filters: Option<&'a str>,
    pub facet_filters: Option<&'a [&'a [&'a str]]>,
    pub facets_distribution: Option<Selectors<&'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
}

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

filters: Option<&'a str>

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

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

Facet names and values to filter on.
Read this page for a complete explanation.

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.

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

impl<'a> Query<'a>[src]

pub fn new(index: &'a Index<'a>) -> Query<'a>[src]

pub fn with_query<'b>(&'b mut self, query: &'a str) -> &'b mut Query<'a>[src]

pub fn with_offset<'b>(&'b mut self, offset: usize) -> &'b mut Query<'a>[src]

pub fn with_limit<'b>(&'b mut self, limit: usize) -> &'b mut Query<'a>[src]

pub fn with_filters<'b>(&'b mut self, filters: &'a str) -> &'b mut Query<'a>[src]

pub fn with_facet_filters<'b>(
    &'b mut self,
    facet_filters: &'a [&'a [&'a str]]
) -> &'b mut Query<'a>
[src]

pub fn with_facets_distribution<'b>(
    &'b mut self,
    facets_distribution: Selectors<&'a [&'a str]>
) -> &'b mut Query<'a>
[src]

pub fn with_attributes_to_retrieve<'b>(
    &'b mut self,
    attributes_to_retrieve: Selectors<&'a [&'a str]>
) -> &'b mut Query<'a>
[src]

pub fn with_attributes_to_crop<'b>(
    &'b mut self,
    attributes_to_crop: Selectors<&'a [(&'a str, Option<usize>)]>
) -> &'b mut Query<'a>
[src]

pub fn with_attributes_to_highlight<'b>(
    &'b mut self,
    attributes_to_highlight: Selectors<&'a [&'a str]>
) -> &'b mut Query<'a>
[src]

pub fn with_crop_length<'b>(
    &'b mut self,
    crop_length: usize
) -> &'b mut Query<'a>
[src]

pub fn with_matches<'b>(&'b mut self, matches: bool) -> &'b mut Query<'a>[src]

pub fn build(&mut self) -> Query<'a>[src]

pub async fn execute<T: 'static + DeserializeOwned>(
    &'a self
) -> Result<SearchResults<T>, Error>
[src]

Execute the query and fetch the results.

Trait Implementations

impl<'a> Clone for Query<'a>[src]

impl<'a> Debug for Query<'a>[src]

impl<'a> Serialize for Query<'a>[src]

Auto Trait Implementations

impl<'a> RefUnwindSafe for Query<'a>

impl<'a> Send for Query<'a>

impl<'a> Sync for Query<'a>

impl<'a> Unpin for Query<'a>

impl<'a> UnwindSafe for Query<'a>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T> Instrument for T[src]

impl<T> Instrument for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.