update milli with the new parser_filter

This commit is contained in:
Tamo 2021-11-04 15:02:36 +01:00
parent b1a0110a47
commit a58bc5bebb
No known key found for this signature in database
GPG Key ID: 20CD8020AFA88D69
6 changed files with 6 additions and 24 deletions

View File

@ -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"

View File

@ -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;

View File

@ -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<T> = std::result::Result<T, error::Error>;

View File

@ -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<VerboseError<Span<'a>>> for Error {
fn from(nom_error: VerboseError<Span<'a>>) -> Self {
UserError::InvalidFilter { input: nom_error.to_string() }.into()
}
}
fn parse<T: FromStr>(tok: &Token) -> Result<T> {
match tok.inner.parse::<T>() {
Ok(t) => Ok(t),
@ -90,11 +82,9 @@ impl<'a> Filter<'a> {
}
pub fn from_str(expression: &'a str) -> Result<Self> {
let condition = match FilterCondition::parse::<GreedyError<Span, ErrorKind>>(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 })
}

View File

@ -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;

View File

@ -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;