mirror of
https://github.com/meilisearch/meilisearch.git
synced 2024-11-30 09:04:59 +08:00
Rewrite the STARTS WITH filter with the MultiOps trait
This commit is contained in:
parent
72f4b8f9e9
commit
d0ce1453a6
@ -7,7 +7,7 @@ pub use filter_parser::{Condition, Error as FPError, FilterCondition, Span, Toke
|
|||||||
use heed::types::DecodeIgnore;
|
use heed::types::DecodeIgnore;
|
||||||
use heed::LazyDecode;
|
use heed::LazyDecode;
|
||||||
use memchr::memmem::{Finder, FinderRev};
|
use memchr::memmem::{Finder, FinderRev};
|
||||||
use roaring::RoaringBitmap;
|
use roaring::{MultiOps, RoaringBitmap};
|
||||||
use serde_json::Value;
|
use serde_json::Value;
|
||||||
|
|
||||||
use super::facet_range_search;
|
use super::facet_range_search;
|
||||||
@ -320,16 +320,13 @@ impl<'a> Filter<'a> {
|
|||||||
return Ok(docids);
|
return Ok(docids);
|
||||||
}
|
}
|
||||||
Condition::StartsWith(val) => {
|
Condition::StartsWith(val) => {
|
||||||
|
// This can be implemented with the string level layers for a faster execution
|
||||||
let prefix = FacetGroupKey { field_id, level: 0, left_bound: val.value() };
|
let prefix = FacetGroupKey { field_id, level: 0, left_bound: val.value() };
|
||||||
// TODO use the roaring::MultiOps trait
|
let docids = strings_db
|
||||||
let mut docids = RoaringBitmap::new();
|
.prefix_iter(rtxn, &prefix)?
|
||||||
for result in
|
.remap_key_type::<DecodeIgnore>()
|
||||||
strings_db.prefix_iter(rtxn, &prefix)?.remap_key_type::<DecodeIgnore>()
|
.map(|result| result.map(|(_, gv)| gv.bitmap))
|
||||||
{
|
.union()?;
|
||||||
let ((), group_value) = result?;
|
|
||||||
docids |= group_value.bitmap;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Ok(docids);
|
return Ok(docids);
|
||||||
}
|
}
|
||||||
Condition::EndsWith(val) => {
|
Condition::EndsWith(val) => {
|
||||||
|
Loading…
Reference in New Issue
Block a user