Struct meilisearch_sdk::documents::DocumentQuery
source · pub struct DocumentQuery<'a> {
pub index: &'a Index,
pub fields: Option<Vec<&'a str>>,
}Fields§
§index: &'a Index§fields: Option<Vec<&'a str>>The fields that should appear in the documents. By default all of the fields are present.
Implementations§
source§impl<'a> DocumentQuery<'a>
impl<'a> DocumentQuery<'a>
pub fn new(index: &Index) -> DocumentQuery<'_>
sourcepub fn with_fields(
&mut self,
fields: impl IntoIterator<Item = &'a str>
) -> &mut DocumentQuery<'a>
pub fn with_fields(
&mut self,
fields: impl IntoIterator<Item = &'a str>
) -> &mut DocumentQuery<'a>
Specify the fields to return in the document.
Example
let index = client.index("document_query_with_fields");
let mut document_query = DocumentQuery::new(&index);
document_query.with_fields(["title"]);sourcepub async fn execute<T: DeserializeOwned + 'static>(
&self,
document_id: &str
) -> Result<T, Error>
pub async fn execute<T: DeserializeOwned + 'static>(
&self,
document_id: &str
) -> Result<T, Error>
Execute the get document query.
Example
#[derive(Debug, Serialize, Deserialize, PartialEq)]
struct MyObject {
id: String,
kind: String,
}
#[derive(Debug, Serialize, Deserialize, PartialEq)]
struct MyObjectReduced {
id: String,
}
let document = DocumentQuery::new(&index).with_fields(["id"]).execute::<MyObjectReduced>("1").await.unwrap();
assert_eq!(
document,
MyObjectReduced { id: "1".to_string() }
);Trait Implementations§
source§impl<'a> Clone for DocumentQuery<'a>
impl<'a> Clone for DocumentQuery<'a>
source§fn clone(&self) -> DocumentQuery<'a>
fn clone(&self) -> DocumentQuery<'a>
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read more