Skip to content
This repository was archived by the owner on Apr 4, 2023. It is now read-only.

Commit 5114686

Browse files
Merge #743
743: Fix finite pagination with placeholder search r=Kerollmops a=ManyTheFish this bug is reproducible on real datasets and is hard to isolate in a simple test. related to: meilisearch/meilisearch#3200 poke `@curquiza` Co-authored-by: ManyTheFish <[email protected]>
2 parents 0276d52 + 3322018 commit 5114686

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

milli/src/search/criteria/initial.rs

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -39,19 +39,24 @@ impl<D: Distinct> Criterion for Initial<'_, D> {
3939
self.answer
4040
.take()
4141
.map(|mut answer| {
42-
if self.exhaustive_number_hits && answer.query_tree.is_some() {
42+
if self.exhaustive_number_hits {
4343
// resolve the whole query tree to retrieve an exhaustive list of documents matching the query.
44-
// then remove the potential soft deleted documents.
45-
let mut candidates = resolve_query_tree(
46-
self.ctx,
47-
answer.query_tree.as_ref().unwrap(),
48-
params.wdcache,
49-
)? - params.excluded_candidates;
44+
let candidates = answer
45+
.query_tree
46+
.as_ref()
47+
.map(|query_tree| resolve_query_tree(self.ctx, query_tree, params.wdcache))
48+
.transpose()?;
49+
50+
// then intersect the candidates with the potential filtered candidates.
51+
let mut candidates = match (candidates, answer.filtered_candidates.take()) {
52+
(Some(candidates), Some(filtered)) => candidates & filtered,
53+
(Some(candidates), None) => candidates,
54+
(None, Some(filtered)) => filtered,
55+
(None, None) => self.ctx.documents_ids()?,
56+
};
5057

51-
// Apply the filters on the documents retrieved with the query tree.
52-
if let Some(ref filtered_candidates) = answer.filtered_candidates {
53-
candidates &= filtered_candidates;
54-
}
58+
// then remove the potential soft deleted documents.
59+
candidates -= params.excluded_candidates;
5560

5661
// because the initial_candidates should be an exhaustive count of the matching documents,
5762
// we precompute the distinct attributes.

0 commit comments

Comments
 (0)