pub enum Expr {
Term {
keywords: Vec<String>,
field: Option<String>,
required: bool,
excluded: bool,
exact: bool,
},
And(Box<Expr>, Box<Expr>),
Or(Box<Expr>, Box<Expr>),
}Expand description
The AST representing a parsed query.
Variants§
Term
A search term, which can represent multiple keywords.
keywords => a list of keywords (possibly tokenized/split)
field => optional field specifier (e.g. Some("title") for title:foo)
required => a leading +
excluded => a leading -
exact => if originally quoted, meaning “no tokenization/splitting”
And(Box<Expr>, Box<Expr>)
Logical AND of two sub-expressions.
Or(Box<Expr>, Box<Expr>)
Logical OR of two sub-expressions.
Implementations§
Source§impl Expr
impl Expr
Sourcepub fn evaluate(
&self,
matched_terms: &HashSet<usize>,
term_indices: &HashMap<String, usize>,
ignore_negatives: bool,
) -> bool
pub fn evaluate( &self, matched_terms: &HashSet<usize>, term_indices: &HashMap<String, usize>, ignore_negatives: bool, ) -> bool
Evaluate whether a set of matched term indices satisfies this logical expression.
- Term: check if all of its keywords are present (optional/required), or if none are present (excluded).
- AND => both sides must match.
- OR => at least one side must match.
ignore_negatives=> if true, excluded terms are basically ignored (they don’t exclude).- Field is ignored in evaluation, per request.
Trait Implementations§
impl StructuralPartialEq for Expr
Auto Trait Implementations§
impl Freeze for Expr
impl RefUnwindSafe for Expr
impl Send for Expr
impl Sync for Expr
impl Unpin for Expr
impl UnwindSafe for Expr
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more