#[non_exhaustive]pub enum QueryNode {
Text(String),
Exact(String),
Phrase(String),
Field {
field: QueryField,
value: String,
},
Filter(FilterKind),
Label(String),
DateRange {
bound: DateBound,
date: DateValue,
},
Size {
op: SizeOp,
bytes: u64,
},
Near {
left: String,
right: String,
distance: u32,
},
And(Box<QueryNode>, Box<QueryNode>),
Or(Box<QueryNode>, Box<QueryNode>),
Not(Box<QueryNode>),
}Expand description
Root AST node for a parsed query.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Text(String)
A bare term. Subject to the backend’s tokenizer/stemmer.
Exact(String)
+word — exact-match form, the backend should disable stemming
for this term. New in v0.1.0; mirrors Gmail’s +word semantics.
Phrase(String)
"quoted phrase" — multi-word phrase.
Field
field:value — e.g. from:alice, subject:invoice.
Filter(FilterKind)
is:unread, has:attachment, etc. See FilterKind.
Label(String)
label:work, category:promotions (categories normalise to
canonical CATEGORY_* labels).
DateRange
after:2024-01-01, older_than:5d, date:today, etc. The
Relative variant deliberately is not resolved to a concrete
date at parse time — backends call
ParserOptions::now_provider to evaluate
it. See the README for the rationale.
Size
size:>5M, larger:200K, etc.
Near
foo AROUND 3 bar — word proximity.
And(Box<QueryNode>, Box<QueryNode>)
Conjunction. parse builds left-associative trees.
Or(Box<QueryNode>, Box<QueryNode>)
Disjunction. Left-associative.
Not(Box<QueryNode>)
-foo or NOT foo.