diff --git a/crates/milli/src/update/new/extract/faceted/mod.rs b/crates/milli/src/update/new/extract/faceted/mod.rs index bfe8efd03..0c012d739 100644 --- a/crates/milli/src/update/new/extract/faceted/mod.rs +++ b/crates/milli/src/update/new/extract/faceted/mod.rs @@ -28,7 +28,6 @@ impl From for FacetKind { impl FacetKind { pub fn extract_from_key(key: &[u8]) -> (FacetKind, &[u8]) { - debug_assert!(key.len() > 3); (FacetKind::from(key[0]), &key[1..]) } } diff --git a/crates/milli/src/update/new/facet_search_builder.rs b/crates/milli/src/update/new/facet_search_builder.rs index 839120540..7eaec95a5 100644 --- a/crates/milli/src/update/new/facet_search_builder.rs +++ b/crates/milli/src/update/new/facet_search_builder.rs @@ -54,23 +54,12 @@ impl<'indexer> FacetSearchBuilder<'indexer> { } } - fn extract_key_data<'k>(&self, key: &'k [u8]) -> Result>> { - match FacetKind::from(key[0]) { - // Only strings are searchable - FacetKind::String => Ok(Some( - FacetGroupKeyCodec::::bytes_decode(&key[1..]) - .map_err(heed::Error::Encoding)?, - )), - _ => Ok(None), - } - } - - pub fn register_from_key(&mut self, deladd: DelAdd, facet_key: &[u8]) -> Result<()> { - let Some(FacetGroupKey { field_id, level: _level, left_bound }) = - self.extract_key_data(facet_key)? - else { - return Ok(()); - }; + pub fn register_from_key( + &mut self, + deladd: DelAdd, + facet_key: FacetGroupKey<&str>, + ) -> Result<()> { + let FacetGroupKey { field_id, level: _level, left_bound } = facet_key; if deladd == DelAdd::Addition { self.registered_facets.entry(field_id).and_modify(|count| *count += 1).or_insert(1); diff --git a/crates/milli/src/update/new/indexer/mod.rs b/crates/milli/src/update/new/indexer/mod.rs index 001f59fe4..70ac7f959 100644 --- a/crates/milli/src/update/new/indexer/mod.rs +++ b/crates/milli/src/update/new/indexer/mod.rs @@ -681,13 +681,11 @@ fn compute_facet_search_database( } EitherOrBoth::Left(result) => { let (key, _) = result?; - facet_search_builder - .register_from_key(DelAdd::Deletion, key.left_bound.as_ref())?; + facet_search_builder.register_from_key(DelAdd::Deletion, key)?; } EitherOrBoth::Right(result) => { let (key, _) = result?; - facet_search_builder - .register_from_key(DelAdd::Addition, key.left_bound.as_ref())?; + facet_search_builder.register_from_key(DelAdd::Addition, key)?; } } }