From 9c0a1cd9fdbad815937d5835720c6b3fd20009fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Renault?= Date: Wed, 4 Sep 2024 17:48:49 +0200 Subject: [PATCH] Introduce the FieldIdFacetExistsDocidsExtractor --- milli/src/update/new/extract/faceted/mod.rs | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/milli/src/update/new/extract/faceted/mod.rs b/milli/src/update/new/extract/faceted/mod.rs index e3c89b0e4..c885fd610 100644 --- a/milli/src/update/new/extract/faceted/mod.rs +++ b/milli/src/update/new/extract/faceted/mod.rs @@ -210,9 +210,23 @@ impl FacetedExtractor for FieldIdFacetStringDocidsExtractor { } } -// Extract fieldid facet isempty docids // Extract fieldid facet isnull docids -// Extract fieldid facet exists docids + +pub struct FieldIdFacetExistsDocidsExtractor; +impl FacetedExtractor for FieldIdFacetExistsDocidsExtractor { + 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]> { + output.extend_from_slice(&field_id.to_be_bytes()); + Some(&*output) + } +} pub struct FieldIdFacetIsEmptyDocidsExtractor; impl FacetedExtractor for FieldIdFacetIsEmptyDocidsExtractor {