Skip to content

Commit 3130f8c

Browse files
author
kaka
committed
feat: support return document vector data with get one document
1 parent 90a153c commit 3130f8c

File tree

1 file changed

+30
-1
lines changed

1 file changed

+30
-1
lines changed

src/documents.rs

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ pub struct DocumentQuery<'a, Http: HttpClient> {
8282
/// The fields that should appear in the documents. By default, all of the fields are present.
8383
#[serde(skip_serializing_if = "Option::is_none")]
8484
pub fields: Option<Vec<&'a str>>,
85+
#[serde(skip_serializing_if = "Option::is_none", rename = "retrieveVectors")]
86+
pub retrieve_vectors: Option<bool>,
8587
}
8688

8789
impl<'a, Http: HttpClient> DocumentQuery<'a, Http> {
@@ -90,6 +92,7 @@ impl<'a, Http: HttpClient> DocumentQuery<'a, Http> {
9092
DocumentQuery {
9193
index,
9294
fields: None,
95+
retrieve_vectors: None,
9396
}
9497
}
9598

@@ -117,6 +120,30 @@ impl<'a, Http: HttpClient> DocumentQuery<'a, Http> {
117120
self
118121
}
119122

123+
/// Return document vector data with search result.
124+
///
125+
/// # Example
126+
///
127+
/// ```
128+
/// # use meilisearch_sdk::{client::*, indexes::*, documents::*};
129+
/// #
130+
/// # let MEILISEARCH_URL = option_env!("MEILISEARCH_URL").unwrap_or("http://localhost:7700");
131+
/// # let MEILISEARCH_API_KEY = option_env!("MEILISEARCH_API_KEY").unwrap_or("masterKey");
132+
/// #
133+
/// # let client = Client::new(MEILISEARCH_URL, Some(MEILISEARCH_API_KEY)).unwrap();
134+
/// let index = client.index("document_query_with_fields");
135+
/// let mut document_query = DocumentQuery::new(&index);
136+
///
137+
/// document_query.with_retrieve_vectors(true);
138+
/// ```
139+
pub fn with_retrieve_vectors(
140+
&mut self,
141+
retrieve_vectors: bool,
142+
) -> &mut DocumentQuery<'a, Http> {
143+
self.retrieve_vectors = Some(retrieve_vectors);
144+
self
145+
}
146+
120147
/// Execute the get document query.
121148
///
122149
/// # Example
@@ -143,7 +170,9 @@ impl<'a, Http: HttpClient> DocumentQuery<'a, Http> {
143170
/// # let index = client.index("document_query_execute");
144171
/// # index.add_or_replace(&[MyObject{id:"1".to_string(), kind:String::from("a kind")},MyObject{id:"2".to_string(), kind:String::from("some kind")}], None).await.unwrap().wait_for_completion(&client, None, None).await.unwrap();
145172
///
146-
/// let document = DocumentQuery::new(&index).with_fields(["id"])
173+
/// let document = DocumentQuery::new(&index)
174+
/// .with_fields(["id"]).
175+
/// .with_retrieve_vectors(true)
147176
/// .execute::<MyObjectReduced>("1")
148177
/// .await
149178
/// .unwrap();

0 commit comments

Comments
 (0)