From 5c5f41d7556df77488d9b6a79de24affc70cb957 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Renault?= Date: Tue, 12 Nov 2019 18:25:33 +0100 Subject: [PATCH] Take attributes to search in into account --- meilidb-http/src/helpers/meilidb.rs | 6 ++++++ meilidb-http/src/routes/search.rs | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/meilidb-http/src/helpers/meilidb.rs b/meilidb-http/src/helpers/meilidb.rs index 0604e9995..8ad202a7f 100644 --- a/meilidb-http/src/helpers/meilidb.rs +++ b/meilidb-http/src/helpers/meilidb.rs @@ -131,6 +131,12 @@ impl<'a> SearchBuilder<'a> { self } + pub fn add_attribute_to_search_in(&mut self, value: String) -> &SearchBuilder { + let attributes_to_search_in = self.attributes_to_search_in.get_or_insert(HashSet::new()); + attributes_to_search_in.insert(value); + self + } + pub fn attributes_to_highlight(&mut self, value: HashSet) -> &SearchBuilder { self.attributes_to_highlight = Some(value); self diff --git a/meilidb-http/src/routes/search.rs b/meilidb-http/src/routes/search.rs index b8981d796..2a2b51a4c 100644 --- a/meilidb-http/src/routes/search.rs +++ b/meilidb-http/src/routes/search.rs @@ -56,7 +56,7 @@ pub async fn search_with_url_query(ctx: Context) -> SResult { } if let Some(attributes_to_search_in) = query.attributes_to_search_in { for attr in attributes_to_search_in.split(',') { - search_builder.add_retrievable_field(attr.to_string()); + search_builder.add_attribute_to_search_in(attr.to_string()); } } if let Some(attributes_to_crop) = query.attributes_to_crop {