mirror of
https://github.com/meilisearch/meilisearch.git
synced 2025-02-21 18:15:29 +08:00
Normalize the value for to compare in the filters
This commit is contained in:
parent
5e12ed38dc
commit
81aee70662
@ -302,7 +302,8 @@ impl<'a> Filter<'a> {
|
|||||||
return Ok(all_ids - docids);
|
return Ok(all_ids - docids);
|
||||||
}
|
}
|
||||||
Condition::Contains(val) => {
|
Condition::Contains(val) => {
|
||||||
let finder = Finder::new(val.value());
|
let value = crate::normalize_facet(val.value());
|
||||||
|
let finder = Finder::new(&value);
|
||||||
let base = FacetGroupKey { field_id, level: 0, left_bound: "" };
|
let base = FacetGroupKey { field_id, level: 0, left_bound: "" };
|
||||||
let docids = strings_db
|
let docids = strings_db
|
||||||
.prefix_iter(rtxn, &base)?
|
.prefix_iter(rtxn, &base)?
|
||||||
@ -323,7 +324,8 @@ impl<'a> Filter<'a> {
|
|||||||
}
|
}
|
||||||
Condition::StartsWith(val) => {
|
Condition::StartsWith(val) => {
|
||||||
// This can be implemented with the string level layers for a faster execution
|
// 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 value = crate::normalize_facet(val.value());
|
||||||
|
let prefix = FacetGroupKey { field_id, level: 0, left_bound: value.as_str() };
|
||||||
let docids = strings_db
|
let docids = strings_db
|
||||||
.prefix_iter(rtxn, &prefix)?
|
.prefix_iter(rtxn, &prefix)?
|
||||||
.remap_key_type::<DecodeIgnore>()
|
.remap_key_type::<DecodeIgnore>()
|
||||||
@ -332,7 +334,8 @@ impl<'a> Filter<'a> {
|
|||||||
return Ok(docids);
|
return Ok(docids);
|
||||||
}
|
}
|
||||||
Condition::EndsWith(val) => {
|
Condition::EndsWith(val) => {
|
||||||
let finder = FinderRev::new(val.value());
|
let value = crate::normalize_facet(val.value());
|
||||||
|
let finder = FinderRev::new(&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: "" };
|
||||||
let docids = strings_db
|
let docids = strings_db
|
||||||
@ -340,9 +343,7 @@ 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)) => {
|
||||||
if finder.rfind(left_bound.as_bytes())
|
if finder.rfind(left_bound) == Some(left_bound.len() - value_len) {
|
||||||
== Some(left_bound.len() - value_len)
|
|
||||||
{
|
|
||||||
Some(lazy_group_value.decode().map(|gv| gv.bitmap))
|
Some(lazy_group_value.decode().map(|gv| gv.bitmap))
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
|
Loading…
x
Reference in New Issue
Block a user