From a58bc5bebbef23550b46ba456c2db3271f6cb2f9 Mon Sep 17 00:00:00 2001 From: Tamo Date: Thu, 4 Nov 2021 15:02:36 +0100 Subject: [PATCH] update milli with the new parser_filter --- milli/Cargo.toml | 3 --- milli/src/facet/mod.rs | 2 -- milli/src/lib.rs | 5 ++--- milli/src/search/facet/filter_condition.rs | 16 +++------------- milli/src/search/facet/mod.rs | 2 -- milli/src/search/mod.rs | 2 +- 6 files changed, 6 insertions(+), 24 deletions(-) diff --git a/milli/Cargo.toml b/milli/Cargo.toml index 1aaeed008..6913178b0 100644 --- a/milli/Cargo.toml +++ b/milli/Cargo.toml @@ -38,10 +38,7 @@ smallvec = "1.6.1" tempfile = "3.2.0" uuid = { version = "0.8.2", features = ["v4"] } -# facet filter parser filter_parser = { path = "../filter_parser" } -nom = "7.0.0" -nom-greedyerror = "0.4.0" # documents words self-join itertools = "0.10.0" diff --git a/milli/src/facet/mod.rs b/milli/src/facet/mod.rs index aaa7a65ce..274d2588d 100644 --- a/milli/src/facet/mod.rs +++ b/milli/src/facet/mod.rs @@ -2,7 +2,5 @@ mod facet_type; mod facet_value; pub mod value_encoding; -pub use filter_parser::{Condition, FilterCondition, FilterParserError, Span, Token}; - pub use self::facet_type::FacetType; pub use self::facet_value::FacetValue; diff --git a/milli/src/lib.rs b/milli/src/lib.rs index e2ecb060c..044d74ec1 100644 --- a/milli/src/lib.rs +++ b/milli/src/lib.rs @@ -17,6 +17,7 @@ use std::collections::{BTreeMap, HashMap}; use std::convert::{TryFrom, TryInto}; use std::hash::BuildHasherDefault; +pub use filter_parser::{Condition, FilterCondition}; use fxhash::{FxHasher32, FxHasher64}; pub use grenad::CompressionType; use serde_json::{Map, Value}; @@ -34,9 +35,7 @@ pub use self::heed_codec::{ RoaringBitmapLenCodec, StrBEU32Codec, StrStrU8Codec, }; pub use self::index::Index; -pub use self::search::{ - Condition, FacetDistribution, Filter, FilterCondition, MatchingWords, Search, SearchResult, -}; +pub use self::search::{FacetDistribution, Filter, MatchingWords, Search, SearchResult}; pub type Result = std::result::Result; diff --git a/milli/src/search/facet/filter_condition.rs b/milli/src/search/facet/filter_condition.rs index b61cd451b..bb342fa27 100644 --- a/milli/src/search/facet/filter_condition.rs +++ b/milli/src/search/facet/filter_condition.rs @@ -3,11 +3,9 @@ use std::ops::Bound::{self, Excluded, Included}; use std::str::FromStr; use either::Either; -pub use filter_parser::{Condition, FilterCondition, FilterParserError, Span, Token}; +pub use filter_parser::{Condition, Error as FPError, FilterCondition, Span, Token}; use heed::types::DecodeIgnore; use log::debug; -use nom::error::{ErrorKind, VerboseError}; -use nom_greedyerror::{convert_error, GreedyError}; use roaring::RoaringBitmap; use super::FacetNumberRange; @@ -22,12 +20,6 @@ pub struct Filter<'a> { condition: FilterCondition<'a>, } -impl<'a> From>> for Error { - fn from(nom_error: VerboseError>) -> Self { - UserError::InvalidFilter { input: nom_error.to_string() }.into() - } -} - fn parse(tok: &Token) -> Result { match tok.inner.parse::() { Ok(t) => Ok(t), @@ -90,11 +82,9 @@ impl<'a> Filter<'a> { } pub fn from_str(expression: &'a str) -> Result { - let condition = match FilterCondition::parse::>(expression) { + let condition = match FilterCondition::parse(expression) { Ok(fc) => Ok(fc), - Err(e) => Err(Error::UserError(UserError::InvalidFilter { - input: convert_error(Span::new_extra(expression, expression), e).to_string(), - })), + Err(e) => Err(Error::UserError(UserError::InvalidFilter { input: e.to_string() })), }?; Ok(Self { condition }) } diff --git a/milli/src/search/facet/mod.rs b/milli/src/search/facet/mod.rs index c0b692de7..d6f276fbb 100644 --- a/milli/src/search/facet/mod.rs +++ b/milli/src/search/facet/mod.rs @@ -1,5 +1,3 @@ -pub use filter_parser::{Condition, FilterCondition}; - pub use self::facet_distribution::FacetDistribution; pub use self::facet_number::{FacetNumberIter, FacetNumberRange, FacetNumberRevRange}; pub use self::facet_string::FacetStringIter; diff --git a/milli/src/search/mod.rs b/milli/src/search/mod.rs index f52dd06f0..a31ead1ec 100644 --- a/milli/src/search/mod.rs +++ b/milli/src/search/mod.rs @@ -14,7 +14,7 @@ use meilisearch_tokenizer::{Analyzer, AnalyzerConfig}; use once_cell::sync::Lazy; use roaring::bitmap::RoaringBitmap; -pub use self::facet::{Condition, FacetDistribution, FacetNumberIter, Filter, FilterCondition}; +pub use self::facet::{FacetDistribution, FacetNumberIter, Filter}; pub use self::matching_words::MatchingWords; use self::query_tree::QueryTreeBuilder; use crate::error::UserError;