This commit is contained in:
刘瀚骋 2021-10-12 22:19:28 +08:00
parent d323e35001
commit 2c65781d91
2 changed files with 7 additions and 10 deletions

View File

@ -1,4 +1,3 @@
use std::fmt::Debug; use std::fmt::Debug;
use std::ops::Bound::{self, Excluded, Included}; use std::ops::Bound::{self, Excluded, Included};
@ -16,9 +15,7 @@ use crate::error::{Error, UserError};
use crate::heed_codec::facet::{ use crate::heed_codec::facet::{
FacetLevelValueF64Codec, FacetStringLevelZeroCodec, FacetStringLevelZeroValueCodec, FacetLevelValueF64Codec, FacetStringLevelZeroCodec, FacetStringLevelZeroValueCodec,
}; };
use crate::{ use crate::{distance_between_two_points, CboRoaringBitmapCodec, FieldId, Index, Result};
distance_between_two_points, CboRoaringBitmapCodec, FieldId, Index, Result,
};
#[derive(Debug, Clone, PartialEq)] #[derive(Debug, Clone, PartialEq)]
pub enum FilterCondition { pub enum FilterCondition {

View File

@ -215,8 +215,7 @@ impl<'a> ParseContext<'a> {
where where
E: ParseError<&'a str> + ContextError<&'a str> + Debug, E: ParseError<&'a str> + ContextError<&'a str> + Debug,
{ {
let err_msg_args_incomplete:&'static str = let err_msg_args_incomplete:&'static str = "_geoRadius. The `_geoRadius` filter expect three arguments: `_geoRadius(latitude, longitude, radius)`";
"_geoRadius. The `_geoRadius` filter expect three arguments: `_geoRadius(latitude, longitude, radius)`";
let err_msg_args_invalid: &'static str = let err_msg_args_invalid: &'static str =
"_geoRadius. Latitude and longitude must be contained between -180 to 180 degrees."; "_geoRadius. Latitude and longitude must be contained between -180 to 180 degrees.";
let (input, args): (&str, Vec<&str>) = match preceded( let (input, args): (&str, Vec<&str>) = match preceded(
@ -530,7 +529,8 @@ mod tests {
&rtxn, &rtxn,
&index, &index,
"(NOT _geoRadius(1, 2, 300) AND _geoRadius(1.001, 2.002, 1000.300)) OR price <= 10", "(NOT _geoRadius(1, 2, 300) AND _geoRadius(1.001, 2.002, 1000.300)) OR price <= 10",
).unwrap(); )
.unwrap();
let expected = FilterCondition::Or( let expected = FilterCondition::Or(
Box::new(FilterCondition::And( Box::new(FilterCondition::And(
Box::new(FilterCondition::Operator(0, GeoGreaterThan([1., 2.], 300.))), Box::new(FilterCondition::Operator(0, GeoGreaterThan([1., 2.], 300.))),