mirror of
https://github.com/meilisearch/MeiliSearch
synced 2024-11-26 14:54:27 +01:00
Run cargo fmt
This commit is contained in:
parent
d10d78d520
commit
196f79115a
@ -164,10 +164,8 @@ fn ws<'a, O>(inner: impl FnMut(Span<'a>) -> IResult<O>) -> impl FnMut(Span<'a>)
|
||||
delimited(multispace0, inner, multispace0)
|
||||
}
|
||||
|
||||
|
||||
/// value_list = (value ("," value)* ","?)?
|
||||
fn parse_value_list<'a>(input: Span<'a>) -> IResult<Vec<Token<'a>>> {
|
||||
|
||||
// TODO: here, I should return a failure with a clear explanation whenever possible
|
||||
// for example:
|
||||
// * expected the name of a field, but got `AND`
|
||||
@ -193,9 +191,10 @@ fn parse_in(input: Span) -> IResult<FilterCondition> {
|
||||
let (input, _) = ws(tag("IN"))(input)?;
|
||||
|
||||
// everything after `IN` can be a failure
|
||||
let (input, _) = cut_with_err(tag("["), |_| {
|
||||
Error::new_from_kind(input, ErrorKind::InOpeningBracket)
|
||||
})(input)?;
|
||||
let (input, _) =
|
||||
cut_with_err(tag("["), |_| Error::new_from_kind(input, ErrorKind::InOpeningBracket))(
|
||||
input,
|
||||
)?;
|
||||
|
||||
let (input, content) = cut(parse_value_list)(input)?;
|
||||
|
||||
@ -218,18 +217,19 @@ fn parse_not_in(input: Span) -> IResult<FilterCondition> {
|
||||
let (input, _) = multispace1(input)?;
|
||||
let (input, _) = ws(tag("IN"))(input)?;
|
||||
|
||||
|
||||
// everything after `IN` can be a failure
|
||||
let (input, _) = cut_with_err(tag("["), |_| {
|
||||
Error::new_from_kind(input, ErrorKind::InOpeningBracket)
|
||||
})(input)?;
|
||||
let (input, _) =
|
||||
cut_with_err(tag("["), |_| Error::new_from_kind(input, ErrorKind::InOpeningBracket))(
|
||||
input,
|
||||
)?;
|
||||
|
||||
let (input, content) = cut(parse_value_list)(input)?;
|
||||
|
||||
// everything after `IN` can be a failure
|
||||
let (input, _) = cut_with_err(tag("]"), |_| {
|
||||
Error::new_from_kind(input, ErrorKind::InClosingBracket)
|
||||
})(input)?;
|
||||
let (input, _) =
|
||||
cut_with_err(tag("]"), |_| Error::new_from_kind(input, ErrorKind::InClosingBracket))(
|
||||
input,
|
||||
)?;
|
||||
|
||||
let filter = FilterCondition::Not(Box::new(FilterCondition::In { fid: value, els: content }));
|
||||
Ok((input, filter))
|
||||
|
@ -302,9 +302,7 @@ impl<'a> Filter<'a> {
|
||||
}
|
||||
Condition::NotEqual(val) => {
|
||||
let operator = Condition::Equal(val.clone());
|
||||
let docids = Self::evaluate_operator(
|
||||
rtxn, index, field_id, &operator,
|
||||
)?;
|
||||
let docids = Self::evaluate_operator(rtxn, index, field_id, &operator)?;
|
||||
let all_ids = index.documents_ids(rtxn)?;
|
||||
return Ok(all_ids - docids);
|
||||
}
|
||||
@ -421,20 +419,30 @@ impl<'a> Filter<'a> {
|
||||
FilterCondition::Or(subfilters) => {
|
||||
let mut bitmap = RoaringBitmap::new();
|
||||
for f in subfilters {
|
||||
bitmap |= Self::inner_evaluate(&(f.clone()).into(), rtxn, index, filterable_fields)?;
|
||||
bitmap |=
|
||||
Self::inner_evaluate(&(f.clone()).into(), rtxn, index, filterable_fields)?;
|
||||
}
|
||||
Ok(bitmap)
|
||||
}
|
||||
FilterCondition::And(subfilters) => {
|
||||
let mut subfilters_iter = subfilters.iter();
|
||||
if let Some(first_subfilter) = subfilters_iter.next() {
|
||||
let mut bitmap =
|
||||
Self::inner_evaluate(&(first_subfilter.clone()).into(), rtxn, index, filterable_fields)?;
|
||||
let mut bitmap = Self::inner_evaluate(
|
||||
&(first_subfilter.clone()).into(),
|
||||
rtxn,
|
||||
index,
|
||||
filterable_fields,
|
||||
)?;
|
||||
for f in subfilters_iter {
|
||||
if bitmap.is_empty() {
|
||||
return Ok(bitmap);
|
||||
}
|
||||
bitmap &= Self::inner_evaluate(&(f.clone()).into(), rtxn, index, filterable_fields)?;
|
||||
bitmap &= Self::inner_evaluate(
|
||||
&(f.clone()).into(),
|
||||
rtxn,
|
||||
index,
|
||||
filterable_fields,
|
||||
)?;
|
||||
}
|
||||
Ok(bitmap)
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user