From 8d11b368d1595cfade894a29fbc3101410eea55f Mon Sep 17 00:00:00 2001 From: Marin Postma Date: Mon, 10 May 2021 18:22:41 +0200 Subject: [PATCH] implement check --- meilisearch-http/src/index/updates.rs | 34 +++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/meilisearch-http/src/index/updates.rs b/meilisearch-http/src/index/updates.rs index c35f21950..44d56ac51 100644 --- a/meilisearch-http/src/index/updates.rs +++ b/meilisearch-http/src/index/updates.rs @@ -75,8 +75,38 @@ impl Settings { } impl Settings { - pub fn check(self) -> Settings { - todo!() + pub fn check(mut self) -> Settings { + let displayed_attributes = match self.displayed_attributes.take() { + Some(Some(fields)) => { + if fields.iter().any(|f| f == "*") { + Some(None) + } else { + Some(Some(fields)) + } + } + otherwise => otherwise, + }; + + let searchable_attributes = match self.searchable_attributes.take() { + Some(Some(fields)) => { + if fields.iter().any(|f| f == "*") { + Some(None) + } else { + Some(Some(fields)) + } + } + otherwise => otherwise, + }; + + Settings { + displayed_attributes, + searchable_attributes, + attributes_for_faceting: self.attributes_for_faceting, + ranking_rules: self.ranking_rules, + stop_words: self.stop_words, + distinct_attribute: self.distinct_attribute, + _kind: PhantomData, + } } }