From 7666e4f34a6c6c73fd231c504c6ea1ef2d12e307 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E7=80=9A=E9=AA=8B?= Date: Thu, 14 Oct 2021 21:37:59 +0800 Subject: [PATCH] follow the suggestions --- milli/Cargo.toml | 2 +- milli/src/search/facet/filter_condition.rs | 4 +--- milli/src/search/facet/filter_parser.rs | 8 +++----- 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/milli/Cargo.toml b/milli/Cargo.toml index 007d9d415..af8370309 100644 --- a/milli/Cargo.toml +++ b/milli/Cargo.toml @@ -39,7 +39,7 @@ tempfile = "3.2.0" uuid = { version = "0.8.2", features = ["v4"] } # facet filter parser -nom = "7" +nom = "7.0.0" # documents words self-join itertools = "0.10.0" diff --git a/milli/src/search/facet/filter_condition.rs b/milli/src/search/facet/filter_condition.rs index c76bb9388..4fedeee69 100644 --- a/milli/src/search/facet/filter_condition.rs +++ b/milli/src/search/facet/filter_condition.rs @@ -24,9 +24,6 @@ pub enum FilterCondition { Empty, } -// impl From - -//for nom impl FilterCondition { pub fn from_array( rtxn: &heed::RoTxn, @@ -72,6 +69,7 @@ impl FilterCondition { Ok(ands) } + pub fn from_str( rtxn: &heed::RoTxn, index: &Index, diff --git a/milli/src/search/facet/filter_parser.rs b/milli/src/search/facet/filter_parser.rs index ee8249069..4d8a54987 100644 --- a/milli/src/search/facet/filter_parser.rs +++ b/milli/src/search/facet/filter_parser.rs @@ -49,6 +49,7 @@ pub trait FilterParserError<'a>: nom::error::ParseError<&'a str> + ContextError<&'a str> + std::fmt::Debug { } + impl<'a> FilterParserError<'a> for VerboseError<&'a str> {} pub struct ParseContext<'a> { @@ -211,7 +212,6 @@ impl<'a> ParseContext<'a> { E: FilterParserError<'a>, { let err_msg_args_incomplete= "_geoRadius. The `_geoRadius` filter expect three arguments: `_geoRadius(latitude, longitude, radius)`"; - let err_msg_latitude_invalid = "_geoRadius. Latitude must be contained between -90 and 90 degrees."; @@ -275,8 +275,7 @@ impl<'a> ParseContext<'a> { let l1 = |c| self.parse_simple_condition(c); let l2 = |c| self.parse_range_condition(c); let l3 = |c| self.parse_geo_radius(c); - let (input, condition) = alt((l1, l2, l3))(input)?; - Ok((input, condition)) + alt((l1, l2, l3))(input) } fn parse_condition_expression(&'a self, input: &'a str) -> IResult<&str, FilterCondition, E> @@ -313,8 +312,7 @@ impl<'a> ParseContext<'a> { where E: FilterParserError<'a>, { - let a = self.parse_or(input); - a + self.parse_or(input) } }