Struct meilisearch_sdk::search::Query [−][src]
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 }
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
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
pub fn with_facet_filters<'b>(
&'b mut self,
facet_filters: &'a [&'a [&'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_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 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> !UnwindSafe for Query<'a>
Blanket Implementations
Mutably borrows from an owned value. Read more
Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more
Instruments this type with the provided Span
, returning an
Instrumented
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