From 72f4b8f9e91a152526465cc9ea2c357f5bf9959f Mon Sep 17 00:00:00 2001 From: Kerollmops Date: Tue, 16 May 2023 10:40:04 +0200 Subject: [PATCH] First implementation of the STARTS WITH filter --- milli/src/search/facet/filter.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/milli/src/search/facet/filter.rs b/milli/src/search/facet/filter.rs index bd213c91d..539b4e5f1 100644 --- a/milli/src/search/facet/filter.rs +++ b/milli/src/search/facet/filter.rs @@ -4,6 +4,7 @@ use std::ops::Bound::{self, Excluded, Included}; use either::Either; pub use filter_parser::{Condition, Error as FPError, FilterCondition, Span, Token}; +use heed::types::DecodeIgnore; use heed::LazyDecode; use memchr::memmem::{Finder, FinderRev}; use roaring::RoaringBitmap; @@ -319,7 +320,17 @@ impl<'a> Filter<'a> { return Ok(docids); } Condition::StartsWith(val) => { - todo!() + let prefix = FacetGroupKey { field_id, level: 0, left_bound: val.value() }; + // TODO use the roaring::MultiOps trait + let mut docids = RoaringBitmap::new(); + for result in + strings_db.prefix_iter(rtxn, &prefix)?.remap_key_type::() + { + let ((), group_value) = result?; + docids |= group_value.bitmap; + } + + return Ok(docids); } Condition::EndsWith(val) => { let finder = FinderRev::new(val.value());