diff --git a/milli/src/update/new/extract/faceted/mod.rs b/milli/src/update/new/extract/faceted/mod.rs index b230549c1..e3c89b0e4 100644 --- a/milli/src/update/new/extract/faceted/mod.rs +++ b/milli/src/update/new/extract/faceted/mod.rs @@ -186,7 +186,6 @@ impl FacetedExtractor for FieldIdFacetNumberDocidsExtractor { } } -/// TODO It doesn't keep the original string in the value pub struct FieldIdFacetStringDocidsExtractor; impl FacetedExtractor for FieldIdFacetStringDocidsExtractor { fn attributes_to_extract<'a>(rtxn: &'a RoTxn, index: &'a Index) -> Result> { @@ -211,6 +210,37 @@ impl FacetedExtractor for FieldIdFacetStringDocidsExtractor { } } +// Extract fieldid facet isempty docids +// Extract fieldid facet isnull docids +// Extract fieldid facet exists docids + +pub struct FieldIdFacetIsEmptyDocidsExtractor; +impl FacetedExtractor for FieldIdFacetIsEmptyDocidsExtractor { + 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]> { + let is_empty = match value { + Value::Null | Value::Bool(_) | Value::Number(_) => false, + Value::String(s) => s.is_empty(), + Value::Array(a) => a.is_empty(), + Value::Object(o) => o.is_empty(), + }; + + if is_empty { + output.extend_from_slice(&field_id.to_be_bytes()); + Some(&*output) + } else { + None + } + } +} + pub fn extract_document_facets( attributes_to_extract: &[&str], obkv: &KvReaderFieldId, diff --git a/milli/src/update/new/indexer/mod.rs b/milli/src/update/new/indexer/mod.rs index 21e28fc84..ed42c03b1 100644 --- a/milli/src/update/new/indexer/mod.rs +++ b/milli/src/update/new/indexer/mod.rs @@ -131,7 +131,9 @@ where // Extract fieldid docid facet number // Extract fieldid docid facet string // Extract facetid string fst + // Extract facetid normalized string strings + // TODO Inverted Indexes again // Extract fieldid facet isempty docids // Extract fieldid facet isnull docids // Extract fieldid facet exists docids