From b33ec9ba3ff098ea08603bc262b6f1d0578e210a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Renault?= Date: Wed, 4 Sep 2024 17:50:08 +0200 Subject: [PATCH] Introduce the FieldIdFacetIsNullDocidsExtractor --- milli/src/update/new/extract/faceted/mod.rs | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/milli/src/update/new/extract/faceted/mod.rs b/milli/src/update/new/extract/faceted/mod.rs index c885fd610..b54219fd3 100644 --- a/milli/src/update/new/extract/faceted/mod.rs +++ b/milli/src/update/new/extract/faceted/mod.rs @@ -210,7 +210,25 @@ impl FacetedExtractor for FieldIdFacetStringDocidsExtractor { } } -// Extract fieldid facet isnull docids +pub struct FieldIdFacetIsNullDocidsExtractor; +impl FacetedExtractor for FieldIdFacetIsNullDocidsExtractor { + fn attributes_to_extract<'a>(rtxn: &'a RoTxn, index: &'a Index) -> Result> { + index.user_defined_faceted_fields(rtxn) + } + + fn build_key<'b>( + field_id: FieldId, + value: &Value, + output: &'b mut Vec, + ) -> Option<&'b [u8]> { + if value.is_null() { + output.extend_from_slice(&field_id.to_be_bytes()); + Some(&*output) + } else { + None + } + } +} pub struct FieldIdFacetExistsDocidsExtractor; impl FacetedExtractor for FieldIdFacetExistsDocidsExtractor {