Struct meilisearch_sdk::search::Query
source · [−]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>,
/* 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
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
sourceimpl<'a> Query<'a>
impl<'a> Query<'a>
pub fn new(index: &'a Index) -> Query<'a>
pub fn with_query<'b>(&'b mut self, query: &'a str) -> &'b mut Query<'a>
pub fn with_offset<'b>(&'b mut self, offset: usize) -> &'b mut Query<'a>
pub fn with_limit<'b>(&'b mut self, limit: usize) -> &'b mut Query<'a>
pub fn with_filter<'b>(&'b mut self, filter: &'a str) -> &'b mut Query<'a>
pub fn with_facets_distribution<'b>(
&'b mut self,
facets_distribution: Selectors<&'a [&'a str]>
) -> &'b mut Query<'a>
pub fn with_sort<'b>(&'b mut self, sort: &'a [&'a str]) -> &'b mut Query<'a>
pub fn with_attributes_to_retrieve<'b>(
&'b mut self,
attributes_to_retrieve: Selectors<&'a [&'a str]>
) -> &'b mut Query<'a>
pub fn with_attributes_to_crop<'b>(
&'b mut self,
attributes_to_crop: Selectors<&'a [(&'a str, Option<usize>)]>
) -> &'b mut Query<'a>
pub fn with_attributes_to_highlight<'b>(
&'b mut self,
attributes_to_highlight: Selectors<&'a [&'a str]>
) -> &'b mut Query<'a>
pub fn with_crop_length<'b>(
&'b mut self,
crop_length: usize
) -> &'b mut Query<'a>
pub fn with_matches<'b>(&'b mut self, matches: bool) -> &'b mut Query<'a>
pub fn build(&mut self) -> Query<'a>
sourcepub async fn execute<T: 'static + DeserializeOwned>(
&'a self
) -> Result<SearchResults<T>, Error>
pub async fn execute<T: 'static + DeserializeOwned>(
&'a self
) -> Result<SearchResults<T>, Error>
Execute the query and fetch the results.
Trait Implementations
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
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Instruments this type with the provided Span, returning an
Instrumented wrapper. Read more
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into)Uses borrowed data to replace owned data, usually by cloning. Read more
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber to this type, returning a
WithDispatch wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber to this type, returning a
WithDispatch wrapper. Read more
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber to this type, returning a
WithDispatch wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber to this type, returning a
WithDispatch wrapper. Read more