mirror of
https://github.com/meilisearch/meilisearch.git
synced 2024-11-26 12:05:05 +08:00
Fix not equal filter when field contains both number and strings
This commit is contained in:
parent
83ad1aaf05
commit
3ff03a3f5f
@ -306,12 +306,7 @@ impl<'a> Filter<'a> {
|
|||||||
return Ok(string_docids | number_docids);
|
return Ok(string_docids | number_docids);
|
||||||
}
|
}
|
||||||
Condition::NotEqual(val) => {
|
Condition::NotEqual(val) => {
|
||||||
let number = val.parse::<f64>().ok();
|
let all_numbers_ids = index.number_faceted_documents_ids(rtxn, field_id)?;
|
||||||
let all_numbers_ids = if number.is_some() {
|
|
||||||
index.number_faceted_documents_ids(rtxn, field_id)?
|
|
||||||
} else {
|
|
||||||
RoaringBitmap::new()
|
|
||||||
};
|
|
||||||
let all_strings_ids = index.string_faceted_documents_ids(rtxn, field_id)?;
|
let all_strings_ids = index.string_faceted_documents_ids(rtxn, field_id)?;
|
||||||
let operator = Condition::Equal(val.clone());
|
let operator = Condition::Equal(val.clone());
|
||||||
let docids = Self::evaluate_operator(
|
let docids = Self::evaluate_operator(
|
||||||
|
@ -43,6 +43,9 @@ test_filter!(eq_mix_and_filter, vec![Right("tag=red"), Right("asc_desc_rank=1")]
|
|||||||
test_filter!(eq_string_or_filter, vec![Left(vec!["tag=red", "tag=green"])]);
|
test_filter!(eq_string_or_filter, vec![Left(vec!["tag=red", "tag=green"])]);
|
||||||
test_filter!(eq_mix_or_filter, vec![Left(vec!["tag=red", "asc_desc_rank=1"])]);
|
test_filter!(eq_mix_or_filter, vec![Left(vec!["tag=red", "asc_desc_rank=1"])]);
|
||||||
test_filter!(eq_number_or_filter, vec![Left(vec!["asc_desc_rank=3", "asc_desc_rank=1"])]);
|
test_filter!(eq_number_or_filter, vec![Left(vec!["asc_desc_rank=3", "asc_desc_rank=1"])]);
|
||||||
|
test_filter!(neq_simple_string_filter, vec![Right("tag!=red")]);
|
||||||
|
test_filter!(neq_simple_number_filter, vec![Right("asc_desc_rank!=1")]);
|
||||||
|
test_filter!(neq_simple_string_in_number_column_filter, vec![Right("asc_desc_rank!=red")]);
|
||||||
test_filter!(geo_radius, vec![Right("_geoRadius(50.630010347667806, 3.086251829166809, 100000)")]);
|
test_filter!(geo_radius, vec![Right("_geoRadius(50.630010347667806, 3.086251829166809, 100000)")]);
|
||||||
test_filter!(
|
test_filter!(
|
||||||
not_geo_radius,
|
not_geo_radius,
|
||||||
|
@ -168,7 +168,15 @@ pub fn expected_order(
|
|||||||
|
|
||||||
fn execute_filter(filter: &str, document: &TestDocument) -> Option<String> {
|
fn execute_filter(filter: &str, document: &TestDocument) -> Option<String> {
|
||||||
let mut id = None;
|
let mut id = None;
|
||||||
if let Some((field, filter)) = filter.split_once("=") {
|
if let Some((field, filter)) = filter.split_once("!=") {
|
||||||
|
if field == "tag" && document.tag != filter {
|
||||||
|
id = Some(document.id.clone())
|
||||||
|
} else if field == "asc_desc_rank"
|
||||||
|
&& Ok(&document.asc_desc_rank) != filter.parse::<u32>().as_ref()
|
||||||
|
{
|
||||||
|
id = Some(document.id.clone())
|
||||||
|
}
|
||||||
|
} else if let Some((field, filter)) = filter.split_once("=") {
|
||||||
if field == "tag" && document.tag == filter {
|
if field == "tag" && document.tag == filter {
|
||||||
id = Some(document.id.clone())
|
id = Some(document.id.clone())
|
||||||
} else if field == "asc_desc_rank"
|
} else if field == "asc_desc_rank"
|
||||||
|
Loading…
Reference in New Issue
Block a user