Improve the estimatedNbHits when distinct is enabled

This commit is contained in:
Kerollmops 2022-06-22 11:37:04 +02:00
parent 4f547eff02
commit d2f84a9d9e
No known key found for this signature in database
GPG Key ID: 92ADA4E935E71FA4

View File

@ -223,7 +223,6 @@ impl<'a> Search<'a> {
debug!("Number of candidates found {}", candidates.len()); debug!("Number of candidates found {}", candidates.len());
let excluded = take(&mut excluded_candidates); let excluded = take(&mut excluded_candidates);
let mut candidates = distinct.distinct(candidates, excluded); let mut candidates = distinct.distinct(candidates, excluded);
initial_candidates |= bucket_candidates; initial_candidates |= bucket_candidates;
@ -236,10 +235,12 @@ impl<'a> Search<'a> {
for candidate in candidates.by_ref().take(self.limit - documents_ids.len()) { for candidate in candidates.by_ref().take(self.limit - documents_ids.len()) {
documents_ids.push(candidate?); documents_ids.push(candidate?);
} }
excluded_candidates |= candidates.into_excluded();
if documents_ids.len() == self.limit { if documents_ids.len() == self.limit {
break; break;
} }
excluded_candidates = candidates.into_excluded();
} }
Ok(SearchResult { Ok(SearchResult {