From 174d69ff727c7213d037e5381fe2dd7b077e3de9 Mon Sep 17 00:00:00 2001 From: Louis Dureuil Date: Tue, 17 Sep 2024 18:16:14 +0200 Subject: [PATCH] Don't override max value in indexes --- meilisearch/src/search/federated.rs | 7 ------ meilisearch/src/search/mod.rs | 35 ++++++++--------------------- 2 files changed, 9 insertions(+), 33 deletions(-) diff --git a/meilisearch/src/search/federated.rs b/meilisearch/src/search/federated.rs index 7efbea20b..94a25a0c9 100644 --- a/meilisearch/src/search/federated.rs +++ b/meilisearch/src/search/federated.rs @@ -496,9 +496,6 @@ pub fn perform_federated_search( // 2. perform queries, merge and make hits index by index let required_hit_count = federation.limit + federation.offset; - let override_max_values_per_facet = - federation.merge_facets.and_then(|merge_facets| merge_facets.max_values_per_facet); - // In step (2), semantic_hit_count will be set to Some(0) if any search kind uses semantic // Then in step (3), we'll update its value if there is any semantic search let mut semantic_hit_count = None; @@ -744,8 +741,6 @@ pub fn perform_federated_search( &index, &rtxn, candidates, - override_max_values_per_facet, - None, super::Route::MultiSearch, ) }) @@ -808,8 +803,6 @@ pub fn perform_federated_search( &index, &rtxn, Default::default(), - override_max_values_per_facet, - None, super::Route::MultiSearch, ) { error.message = diff --git a/meilisearch/src/search/mod.rs b/meilisearch/src/search/mod.rs index 4d5d8d890..5bba40a07 100644 --- a/meilisearch/src/search/mod.rs +++ b/meilisearch/src/search/mod.rs @@ -990,15 +990,7 @@ pub fn perform_search( let (facet_distribution, facet_stats) = facets .map(move |facets| { - compute_facet_distribution_stats( - &facets, - index, - &rtxn, - candidates, - None, - None, - Route::Search, - ) + compute_facet_distribution_stats(&facets, index, &rtxn, candidates, Route::Search) }) .transpose()? .map(|ComputedFacets { distribution, stats }| (distribution, stats)) @@ -1034,39 +1026,30 @@ fn compute_facet_distribution_stats>( index: &Index, rtxn: &RoTxn, candidates: roaring::RoaringBitmap, - override_max_values_per_facet: Option, - override_sort_facet_values_by: Option, route: Route, ) -> Result { let mut facet_distribution = index.facets_distribution(rtxn); - let max_values_by_facet = match override_max_values_per_facet { - Some(max_values_by_facet) => max_values_by_facet, - None => index - .max_values_per_facet(rtxn) - .map_err(milli::Error::from)? - .map(|x| x as usize) - .unwrap_or(DEFAULT_VALUES_PER_FACET), - }; + let max_values_by_facet = index + .max_values_per_facet(rtxn) + .map_err(milli::Error::from)? + .map(|x| x as usize) + .unwrap_or(DEFAULT_VALUES_PER_FACET); facet_distribution.max_values_per_facet(max_values_by_facet); let sort_facet_values_by = index.sort_facet_values_by(rtxn).map_err(milli::Error::from)?; - let sort_facet_values_by = |n: &str| match override_sort_facet_values_by { - Some(order_by) => order_by, - None => sort_facet_values_by.get(n), - }; - // add specific facet if there is no placeholder if facets.iter().all(|f| f.as_ref() != "*") { - let fields: Vec<_> = facets.iter().map(|n| (n, sort_facet_values_by(n.as_ref()))).collect(); + let fields: Vec<_> = + facets.iter().map(|n| (n, sort_facet_values_by.get(n.as_ref()))).collect(); facet_distribution.facets(fields); } let distribution = facet_distribution .candidates(candidates) - .default_order_by(sort_facet_values_by("*")) + .default_order_by(sort_facet_values_by.get("*")) .execute() .map_err(|error| match (error, route) { (