From fea9ffc46a92a0f9c7f295dd2379317a2719c94a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Renault?= Date: Wed, 17 Feb 2021 17:50:46 +0100 Subject: [PATCH] Use the bucket candidates in the search module --- milli/src/search/mod.rs | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/milli/src/search/mod.rs b/milli/src/search/mod.rs index 89abb01b4..d94bc8831 100644 --- a/milli/src/search/mod.rs +++ b/milli/src/search/mod.rs @@ -294,19 +294,24 @@ impl<'a> Search<'a> { let mut offset = self.offset; let mut limit = self.limit; let mut documents_ids = Vec::new(); - while let Some(CriterionResult { candidates: docids, .. }) = criteria.next()? { + let mut initial_candidates = RoaringBitmap::new(); + while let Some(CriterionResult { candidates, bucket_candidates, .. }) = criteria.next()? { - let mut len = docids.len() as usize; - let mut docids = docids.into_iter(); + let mut len = candidates.len() as usize; + let mut candidates = candidates.into_iter(); + + if let Some(docids) = bucket_candidates { + initial_candidates.union_with(&docids); + } if offset != 0 { - docids.by_ref().skip(offset).for_each(drop); + candidates.by_ref().skip(offset).for_each(drop); offset = offset.saturating_sub(len.min(offset)); len = len.saturating_sub(len.min(offset)); } if len != 0 { - documents_ids.extend(docids.take(limit)); + documents_ids.extend(candidates.take(limit)); limit = limit.saturating_sub(len.min(limit)); } @@ -314,8 +319,7 @@ impl<'a> Search<'a> { } let found_words = HashSet::new(); - let candidates = RoaringBitmap::new(); - Ok(SearchResult { found_words, candidates, documents_ids }) + Ok(SearchResult { found_words, candidates: initial_candidates, documents_ids }) // let order_by_facet = { // let criteria = self.index.criteria(self.rtxn)?;