From 3b1f908e5e80335d517c8eb1dd5e35952d45b49a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Lecrenier?= Date: Mon, 17 Oct 2022 12:48:10 +0200 Subject: [PATCH] Revert behaviour of facet distribution to what it was before Where the docid that is used to get the original facet string value definitely belongs to the candidates --- milli/src/search/facet/facet_distribution_iter.rs | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/milli/src/search/facet/facet_distribution_iter.rs b/milli/src/search/facet/facet_distribution_iter.rs index 0fdca4118..9cd85b667 100644 --- a/milli/src/search/facet/facet_distribution_iter.rs +++ b/milli/src/search/facet/facet_distribution_iter.rs @@ -74,13 +74,12 @@ where if key.field_id != self.field_id { return Ok(ControlFlow::Break(())); } - // TODO: use real intersection and then take min()? - let docids_in_common = value.bitmap.intersection_len(candidates); - if docids_in_common > 0 { - // TODO: use min() - let any_docid = value.bitmap.iter().next().unwrap(); - match (self.callback)(key.left_bound, docids_in_common, any_docid)? { - ControlFlow::Continue(_) => (), // TODO use unit instead of empty scope + let docids_in_common = value.bitmap & candidates; + if !docids_in_common.is_empty() { + let any_docid_in_common = docids_in_common.min().unwrap(); + match (self.callback)(key.left_bound, docids_in_common.len(), any_docid_in_common)? + { + ControlFlow::Continue(_) => (), ControlFlow::Break(_) => return Ok(ControlFlow::Break(())), } }