From 7dbefae1e39d20fb5183ecc1651da063ed2e5d97 Mon Sep 17 00:00:00 2001 From: many Date: Thu, 12 Aug 2021 17:23:39 +0200 Subject: [PATCH] Make facet string iterator non reducing --- milli/src/search/facet/facet_string.rs | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/milli/src/search/facet/facet_string.rs b/milli/src/search/facet/facet_string.rs index 40ea8c04a..ed5322607 100644 --- a/milli/src/search/facet/facet_string.rs +++ b/milli/src/search/facet/facet_string.rs @@ -289,6 +289,7 @@ pub struct FacetStringIter<'t> { field_id: FieldId, level_iters: Vec<(RoaringBitmap, Either, FacetStringLevelZeroRange<'t>>)>, + must_reduce: bool, } impl<'t> FacetStringIter<'t> { @@ -318,7 +319,13 @@ impl<'t> FacetStringIter<'t> { )?), }; - Ok(FacetStringIter { rtxn, db, field_id, level_iters: vec![(documents_ids, highest_iter)] }) + Ok(FacetStringIter { + rtxn, + db, + field_id, + level_iters: vec![(documents_ids, highest_iter)], + must_reduce: false, + }) } fn highest_level( @@ -348,7 +355,9 @@ impl<'t> Iterator for FacetStringIter<'t> { Ok(((level, left, right), (string_bounds, mut docids))) => { docids &= &*documents_ids; if !docids.is_empty() { - *documents_ids -= &docids; + if self.must_reduce { + *documents_ids -= &docids; + } let result = match string_bounds { Some((left, right)) => FacetStringLevelZeroRange::new( @@ -390,7 +399,9 @@ impl<'t> Iterator for FacetStringIter<'t> { Ok((normalized, original, mut docids)) => { docids &= &*documents_ids; if !docids.is_empty() { - *documents_ids -= &docids; + if self.must_reduce { + *documents_ids -= &docids; + } return Some(Ok((normalized, original, docids))); } }