diff --git a/crates/milli/src/update/facet/new_incremental.rs b/crates/milli/src/update/facet/new_incremental.rs index 82e1c31fb..e917e41b6 100644 --- a/crates/milli/src/update/facet/new_incremental.rs +++ b/crates/milli/src/update/facet/new_incremental.rs @@ -91,8 +91,12 @@ impl FacetsUpdateIncrementalInner { FacetGroupKey { field_id: self.field_id, level: parent_level, left_bound: &[] }; let mut last_parent: Option> = None; - let mut child_it = - changed_children.drain(..).filter(|child| valid_facet_value(&child.facet_value)); + let mut child_it = changed_children + // drain all changed children + .drain(..) + // keep only children whose value is valid in the LMDB sense + .filter(|child| valid_facet_value(&child.facet_value)); + // `while let` rather than `for` because we advance `child_it` inside of the loop 'current_level: while let Some(child) = child_it.next() { if let Some(last_parent) = &last_parent { if &child.facet_value >= last_parent {