Struct meilisearch_sdk::documents::DocumentsQuery
source · pub struct DocumentsQuery<'a> {
pub index: &'a Index,
pub offset: Option<usize>,
pub limit: Option<usize>,
pub fields: Option<Vec<&'a str>>,
pub filter: Option<&'a str>,
}Fields§
§index: &'a Index§offset: Option<usize>The number of documents to skip.
If the value of the parameter offset is n, the n first documents 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
fields: Option<Vec<&'a str>>The fields that should appear in the documents. By default all of the fields are present.
filter: Option<&'a str>Filters to apply.
Available since v1.2 of Meilisearch Read the dedicated guide to learn the syntax.
Implementations§
source§impl<'a> DocumentsQuery<'a>
impl<'a> DocumentsQuery<'a>
pub fn new(index: &Index) -> DocumentsQuery<'_>
sourcepub fn with_offset(&mut self, offset: usize) -> &mut DocumentsQuery<'a>
pub fn with_offset(&mut self, offset: usize) -> &mut DocumentsQuery<'a>
Specify the offset.
Example
let index = client.index("my_index");
let mut documents_query = DocumentsQuery::new(&index).with_offset(1);sourcepub fn with_limit(&mut self, limit: usize) -> &mut DocumentsQuery<'a>
pub fn with_limit(&mut self, limit: usize) -> &mut DocumentsQuery<'a>
Specify the limit.
Example
let index = client.index("my_index");
let mut documents_query = DocumentsQuery::new(&index);
documents_query.with_limit(1);sourcepub fn with_fields(
&mut self,
fields: impl IntoIterator<Item = &'a str>
) -> &mut DocumentsQuery<'a>
pub fn with_fields( &mut self, fields: impl IntoIterator<Item = &'a str> ) -> &mut DocumentsQuery<'a>
Specify the fields to return in the documents.
Example
let index = client.index("my_index");
let mut documents_query = DocumentsQuery::new(&index);
documents_query.with_fields(["title"]);pub fn with_filter<'b>( &'b mut self, filter: &'a str ) -> &'b mut DocumentsQuery<'a>
sourcepub async fn execute<T: DeserializeOwned + 'static>(
&self
) -> Result<DocumentsResults<T>, Error>
pub async fn execute<T: DeserializeOwned + 'static>( &self ) -> Result<DocumentsResults<T>, Error>
Execute the get documents query.
Example
#[derive(Debug, Serialize, Deserialize, PartialEq)]
struct MyObject {
id: Option<usize>,
kind: String,
}
let index = client.index("documents_query_execute");
let document = DocumentsQuery::new(&index)
.with_offset(1)
.execute::<MyObject>()
.await
.unwrap();
Trait Implementations§
source§impl<'a> Clone for DocumentsQuery<'a>
impl<'a> Clone for DocumentsQuery<'a>
source§fn clone(&self) -> DocumentsQuery<'a>
fn clone(&self) -> DocumentsQuery<'a>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more