From 7a737d2bd35c01049527c30f16ae9423cd51ab93 Mon Sep 17 00:00:00 2001 From: Marin Postma Date: Tue, 20 Apr 2021 13:10:50 +0200 Subject: [PATCH] support wildcard --- meilisearch-http/src/index/search.rs | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/meilisearch-http/src/index/search.rs b/meilisearch-http/src/index/search.rs index bc9554864..4f796476c 100644 --- a/meilisearch-http/src/index/search.rs +++ b/meilisearch-http/src/index/search.rs @@ -41,7 +41,7 @@ pub struct SearchQuery { pub struct SearchHit { #[serde(flatten)] pub document: Document, - #[serde(rename = "_formatted", skip_serializing_if = "Map::is_empty")] + #[serde(rename = "_formatted", skip_serializing_if = "Document::is_empty")] pub formatted: Document, } @@ -88,15 +88,23 @@ impl Index { let mut documents = Vec::new(); let fields_ids_map = self.fields_ids_map(&rtxn).unwrap(); - let fids = |attrs: &HashSet| { - attrs - .iter() - .filter_map(|name| fields_ids_map.id(name)) - .collect() - }; - let displayed_ids: HashSet = fields_ids_map.iter().map(|(id, _)| id).collect(); + let fids = |attrs: &HashSet| { + let mut ids = HashSet::new(); + for attr in attrs { + if attr == "*" { + ids = displayed_ids.clone(); + break; + } + + if let Some(id) = fields_ids_map.id(attr) { + ids.insert(id); + } + } + ids + }; + let to_retrieve_ids = query .attributes_to_retrieve .as_ref()