mirror of
https://github.com/meilisearch/meilisearch.git
synced 2024-11-27 04:25:06 +08:00
Rewrite the ENDS WITH filter with the MultiOps trait
This commit is contained in:
parent
50629cf735
commit
5e12ed38dc
@ -13,7 +13,7 @@ use serde_json::Value;
|
|||||||
use super::facet_range_search;
|
use super::facet_range_search;
|
||||||
use crate::error::{Error, UserError};
|
use crate::error::{Error, UserError};
|
||||||
use crate::heed_codec::facet::{
|
use crate::heed_codec::facet::{
|
||||||
FacetGroupKey, FacetGroupKeyCodec, FacetGroupValue, FacetGroupValueCodec, OrderedF64Codec,
|
FacetGroupKey, FacetGroupKeyCodec, FacetGroupValueCodec, OrderedF64Codec,
|
||||||
};
|
};
|
||||||
use crate::{distance_between_two_points, lat_lng_to_xyz, FieldId, Index, Result};
|
use crate::{distance_between_two_points, lat_lng_to_xyz, FieldId, Index, Result};
|
||||||
|
|
||||||
@ -309,9 +309,10 @@ impl<'a> Filter<'a> {
|
|||||||
.remap_data_type::<LazyDecode<FacetGroupValueCodec>>()
|
.remap_data_type::<LazyDecode<FacetGroupValueCodec>>()
|
||||||
.filter_map(|result| match result {
|
.filter_map(|result| match result {
|
||||||
Ok((FacetGroupKey { left_bound, .. }, lazy_group_value)) => {
|
Ok((FacetGroupKey { left_bound, .. }, lazy_group_value)) => {
|
||||||
match finder.find(left_bound.as_bytes()) {
|
if finder.find(left_bound.as_bytes()).is_some() {
|
||||||
Some(_) => Some(lazy_group_value.decode().map(|gv| gv.bitmap)),
|
Some(lazy_group_value.decode().map(|gv| gv.bitmap))
|
||||||
None => None,
|
} else {
|
||||||
|
None
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Err(e) => Some(Err(e)),
|
Err(e) => Some(Err(e)),
|
||||||
@ -334,18 +335,22 @@ impl<'a> Filter<'a> {
|
|||||||
let finder = FinderRev::new(val.value());
|
let finder = FinderRev::new(val.value());
|
||||||
let value_len = finder.needle().len();
|
let value_len = finder.needle().len();
|
||||||
let base = FacetGroupKey { field_id, level: 0, left_bound: "" };
|
let base = FacetGroupKey { field_id, level: 0, left_bound: "" };
|
||||||
// TODO use the roaring::MultiOps trait
|
let docids = strings_db
|
||||||
let mut docids = RoaringBitmap::new();
|
|
||||||
for result in strings_db
|
|
||||||
.prefix_iter(rtxn, &base)?
|
.prefix_iter(rtxn, &base)?
|
||||||
.remap_data_type::<LazyDecode<FacetGroupValueCodec>>()
|
.remap_data_type::<LazyDecode<FacetGroupValueCodec>>()
|
||||||
|
.filter_map(|result| match result {
|
||||||
|
Ok((FacetGroupKey { left_bound, .. }, lazy_group_value)) => {
|
||||||
|
if finder.rfind(left_bound.as_bytes())
|
||||||
|
== Some(left_bound.len() - value_len)
|
||||||
{
|
{
|
||||||
let (FacetGroupKey { left_bound, .. }, lazy_group_value) = result?;
|
Some(lazy_group_value.decode().map(|gv| gv.bitmap))
|
||||||
if finder.rfind(left_bound.as_bytes()) == Some(left_bound.len() - value_len) {
|
} else {
|
||||||
let FacetGroupValue { bitmap, .. } = lazy_group_value.decode()?;
|
None
|
||||||
docids |= bitmap;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Err(e) => Some(Err(e)),
|
||||||
|
})
|
||||||
|
.union()?;
|
||||||
|
|
||||||
return Ok(docids);
|
return Ok(docids);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user