From 18bbadf6455f21407d78a8e485857be1d23b888e Mon Sep 17 00:00:00 2001 From: Louis Dureuil Date: Thu, 19 Oct 2023 15:58:25 +0200 Subject: [PATCH] Add explanatory comment --- milli/src/search/new/bucket_sort.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/milli/src/search/new/bucket_sort.rs b/milli/src/search/new/bucket_sort.rs index df9c14c7d..b46f6124f 100644 --- a/milli/src/search/new/bucket_sort.rs +++ b/milli/src/search/new/bucket_sort.rs @@ -60,6 +60,9 @@ pub fn bucket_sort<'ctx, Q: RankingRuleQueryTrait>( let mut all_candidates = universe - excluded; all_candidates.extend(results.iter().copied()); + // drain the results of the skipped elements + // this **must** be done **after** writing the entire results in `all_candidates` to ensure + // e.g. estimatedTotalHits is correct. if results.len() >= from { results.drain(..from); } else {