From 52a494bd3b75cda4bb045650ae73bd8dce51b335 Mon Sep 17 00:00:00 2001 From: Kerollmops Date: Wed, 8 Jun 2022 16:54:16 +0200 Subject: [PATCH] Add the new pagination.limited_to and faceting.max_values_per_facet settings --- milli/src/update/settings.rs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/milli/src/update/settings.rs b/milli/src/update/settings.rs index 9363d8eb6..86c168be3 100644 --- a/milli/src/update/settings.rs +++ b/milli/src/update/settings.rs @@ -104,6 +104,8 @@ pub struct Settings<'a, 't, 'u, 'i> { exact_words: Setting>, /// Attributes on which typo tolerance is disabled. exact_attributes: Setting>, + max_values_per_facet: Setting, + limit_pagination_to: Setting, } impl<'a, 't, 'u, 'i> Settings<'a, 't, 'u, 'i> { @@ -129,6 +131,8 @@ impl<'a, 't, 'u, 'i> Settings<'a, 't, 'u, 'i> { min_word_len_two_typos: Setting::NotSet, min_word_len_one_typo: Setting::NotSet, exact_attributes: Setting::NotSet, + max_values_per_facet: Setting::NotSet, + limit_pagination_to: Setting::NotSet, indexer_config, } } @@ -246,6 +250,22 @@ impl<'a, 't, 'u, 'i> Settings<'a, 't, 'u, 'i> { self.exact_attributes = Setting::Reset; } + pub fn set_max_values_per_facet(&mut self, value: usize) { + self.max_values_per_facet = Setting::Set(value); + } + + pub fn reset_max_values_per_facet(&mut self) { + self.max_values_per_facet = Setting::Reset; + } + + pub fn set_limit_pagination_to(&mut self, value: usize) { + self.limit_pagination_to = Setting::Set(value); + } + + pub fn reset_limit_pagination_to(&mut self) { + self.limit_pagination_to = Setting::Reset; + } + fn reindex(&mut self, cb: &F, old_fields_ids_map: FieldsIdsMap) -> Result<()> where F: Fn(UpdateIndexingStep) + Sync, @@ -1525,6 +1545,8 @@ mod tests { min_word_len_one_typo, exact_words, exact_attributes, + max_values_per_facet, + limit_pagination_to, } = builder; assert!(matches!(searchable_fields, Setting::NotSet)); @@ -1541,5 +1563,7 @@ mod tests { assert!(matches!(min_word_len_one_typo, Setting::NotSet)); assert!(matches!(exact_words, Setting::NotSet)); assert!(matches!(exact_attributes, Setting::NotSet)); + assert!(matches!(max_values_per_facet, Setting::NotSet)); + assert!(matches!(limit_pagination_to, Setting::NotSet)); } }