mirror of
https://github.com/meilisearch/MeiliSearch
synced 2025-07-03 20:07:09 +02:00
feat(http): update the documents resource
- Return Documents API resources on `/documents` in an array in the the results field. - Add limit, offset and total in the response body. - Rename `attributesToRetrieve` into `fields` (only for the `/documents` endpoints, not for the `/search` ones). - The `displayedAttributes` settings does not impact anymore the displayed fields returned in the `/documents` endpoints. These settings only impacts the `/search` endpoint. Fix #2372
This commit is contained in:
parent
ab39df9693
commit
ddad6cc069
11 changed files with 217 additions and 200 deletions
|
@ -145,9 +145,12 @@ impl Index<'_> {
|
|||
pub async fn get_document(
|
||||
&self,
|
||||
id: u64,
|
||||
_options: Option<GetDocumentOptions>,
|
||||
options: Option<GetDocumentOptions>,
|
||||
) -> (Value, StatusCode) {
|
||||
let url = format!("/indexes/{}/documents/{}", encode(self.uid.as_ref()), id);
|
||||
let mut url = format!("/indexes/{}/documents/{}", encode(self.uid.as_ref()), id);
|
||||
if let Some(fields) = options.and_then(|o| o.fields) {
|
||||
url.push_str(&format!("?fields={}", fields.join(",")));
|
||||
}
|
||||
self.service.get(url).await
|
||||
}
|
||||
|
||||
|
@ -162,10 +165,7 @@ impl Index<'_> {
|
|||
}
|
||||
|
||||
if let Some(attributes_to_retrieve) = options.attributes_to_retrieve {
|
||||
url.push_str(&format!(
|
||||
"attributesToRetrieve={}&",
|
||||
attributes_to_retrieve.join(",")
|
||||
));
|
||||
url.push_str(&format!("fields={}&", attributes_to_retrieve.join(",")));
|
||||
}
|
||||
|
||||
self.service.get(url).await
|
||||
|
@ -245,7 +245,9 @@ impl Index<'_> {
|
|||
make_settings_test_routes!(distinct_attribute);
|
||||
}
|
||||
|
||||
pub struct GetDocumentOptions;
|
||||
pub struct GetDocumentOptions {
|
||||
pub fields: Option<Vec<&'static str>>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
pub struct GetAllDocumentsOptions {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue