From d2f84a9d9e60bb027c543718426f27fe288b6bbf Mon Sep 17 00:00:00 2001 From: Kerollmops Date: Wed, 22 Jun 2022 11:37:04 +0200 Subject: [PATCH] Improve the estimatedNbHits when distinct is enabled --- milli/src/search/mod.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/milli/src/search/mod.rs b/milli/src/search/mod.rs index 1c363e142..447ba4984 100644 --- a/milli/src/search/mod.rs +++ b/milli/src/search/mod.rs @@ -223,7 +223,6 @@ impl<'a> Search<'a> { debug!("Number of candidates found {}", candidates.len()); let excluded = take(&mut excluded_candidates); - let mut candidates = distinct.distinct(candidates, excluded); initial_candidates |= bucket_candidates; @@ -236,10 +235,12 @@ impl<'a> Search<'a> { for candidate in candidates.by_ref().take(self.limit - documents_ids.len()) { documents_ids.push(candidate?); } + + excluded_candidates |= candidates.into_excluded(); + if documents_ids.len() == self.limit { break; } - excluded_candidates = candidates.into_excluded(); } Ok(SearchResult {