Use the bucket candidates in the search module

This commit is contained in:
Clément Renault 2021-02-17 17:50:46 +01:00 committed by Kerollmops
parent 229130ed25
commit fea9ffc46a
No known key found for this signature in database
GPG Key ID: 92ADA4E935E71FA4

View File

@ -294,19 +294,24 @@ impl<'a> Search<'a> {
let mut offset = self.offset; let mut offset = self.offset;
let mut limit = self.limit; let mut limit = self.limit;
let mut documents_ids = Vec::new(); 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 len = candidates.len() as usize;
let mut docids = docids.into_iter(); let mut candidates = candidates.into_iter();
if let Some(docids) = bucket_candidates {
initial_candidates.union_with(&docids);
}
if offset != 0 { 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)); offset = offset.saturating_sub(len.min(offset));
len = len.saturating_sub(len.min(offset)); len = len.saturating_sub(len.min(offset));
} }
if len != 0 { if len != 0 {
documents_ids.extend(docids.take(limit)); documents_ids.extend(candidates.take(limit));
limit = limit.saturating_sub(len.min(limit)); limit = limit.saturating_sub(len.min(limit));
} }
@ -314,8 +319,7 @@ impl<'a> Search<'a> {
} }
let found_words = HashSet::new(); let found_words = HashSet::new();
let candidates = RoaringBitmap::new(); Ok(SearchResult { found_words, candidates: initial_candidates, documents_ids })
Ok(SearchResult { found_words, candidates, documents_ids })
// let order_by_facet = { // let order_by_facet = {
// let criteria = self.index.criteria(self.rtxn)?; // let criteria = self.index.criteria(self.rtxn)?;