From 3d7ed3263f3cfb4eed14b446de62f04dc9ef6efa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Lecrenier?= Date: Wed, 7 Sep 2022 18:00:00 +0200 Subject: [PATCH] Fix bug in string facet distribution with few candidates --- milli/src/search/facet/facet_distribution.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/milli/src/search/facet/facet_distribution.rs b/milli/src/search/facet/facet_distribution.rs index 7eb438a03..0eaeec399 100644 --- a/milli/src/search/facet/facet_distribution.rs +++ b/milli/src/search/facet/facet_distribution.rs @@ -96,7 +96,7 @@ impl<'a> FacetDistribution<'a> { let mut key_buffer: Vec<_> = field_id.to_be_bytes().iter().copied().collect(); let db = self.index.field_id_docid_facet_strings; - for docid in candidates.into_iter() { + 'outer: for docid in candidates.into_iter() { key_buffer.truncate(mem::size_of::()); key_buffer.extend_from_slice(&docid.to_be_bytes()); let iter = db @@ -112,7 +112,7 @@ impl<'a> FacetDistribution<'a> { *count += 1; if normalized_distribution.len() == self.max_values_per_facet { - break; + break 'outer; } } } @@ -393,7 +393,7 @@ mod tests { .execute() .unwrap(); - milli_snap!(format!("{map:?}"), @r###"{"colour": {"Blue": 2, "RED": 1}}"###); + milli_snap!(format!("{map:?}"), @r###"{"colour": {"Blue": 1}}"###); } #[test]