pub enum FormulaExpr {
Show 22 variants
Constant {
value: f64,
},
Variable {
name: String,
},
Sum {
left: Box<FormulaExpr>,
right: Box<FormulaExpr>,
},
Sub {
left: Box<FormulaExpr>,
right: Box<FormulaExpr>,
},
Mul {
left: Box<FormulaExpr>,
right: Box<FormulaExpr>,
},
Div {
left: Box<FormulaExpr>,
right: Box<FormulaExpr>,
by_zero_default: Option<f64>,
},
Neg {
operand: Box<FormulaExpr>,
},
Abs {
x: Box<FormulaExpr>,
},
Sqrt {
x: Box<FormulaExpr>,
domain_default: Option<f64>,
},
Log {
x: Box<FormulaExpr>,
domain_default: Option<f64>,
},
Ln {
x: Box<FormulaExpr>,
domain_default: Option<f64>,
},
Exp {
x: Box<FormulaExpr>,
},
Acosh {
x: Box<FormulaExpr>,
domain_default: Option<f64>,
},
Pow {
base: Box<FormulaExpr>,
exponent: Box<FormulaExpr>,
},
Max {
args: Vec<FormulaExpr>,
},
Min {
args: Vec<FormulaExpr>,
},
GeoDistance {
lat: f64,
lon: f64,
field: String,
},
Decay {
kind: String,
x: Box<FormulaExpr>,
target: Option<Box<FormulaExpr>>,
scale: Option<f64>,
midpoint: Option<f64>,
},
Case {
cond: Box<FilterExpr>,
then_: Box<FormulaExpr>,
else_: Box<FormulaExpr>,
},
MatchCondition {
field: String,
values: Vec<Value>,
},
Datetime {
value: String,
},
DatetimeKey {
key: String,
},
}Expand description
Formula expression tree evaluated by QUERY FORMULA to rescore points.
Variants§
Constant
Numeric literal.
Variable
Variable reference: $score, a DEFAULTS-bound name, or a datetime key.
Sum
left + right.
Sub
left - right.
Mul
left * right.
Div
left / right, with optional [DEFAULT n] zero-division fallback.
Neg
Unary negation.
Fields
operand: Box<FormulaExpr>Expression to negate.
Abs
ABS(x).
Fields
x: Box<FormulaExpr>Argument.
Sqrt
SQRT(x) with optional [DEFAULT n] negative fallback.
Fields
x: Box<FormulaExpr>Argument.
Log
LOG(x) — base-10 logarithm with optional [DEFAULT n] non-positive fallback.
Fields
x: Box<FormulaExpr>Argument.
Ln
LN(x) — natural logarithm with optional [DEFAULT n] non-positive fallback.
Fields
x: Box<FormulaExpr>Argument.
Exp
EXP(x) — e raised to x.
Fields
x: Box<FormulaExpr>Argument.
Acosh
ACOSH(x) — inverse hyperbolic cosine with optional [DEFAULT n] fallback.
Fields
x: Box<FormulaExpr>Argument.
Pow
POW(base, exponent).
Max
N-ary MAX(...). At least one operand (parser-enforced).
Fields
args: Vec<FormulaExpr>Folded operands (n >= 1).
Min
N-ary MIN(...). At least one operand (parser-enforced).
Fields
args: Vec<FormulaExpr>Folded operands (n >= 1).
GeoDistance
GEO_DISTANCE(lat, lon, field) — meters between the coordinate and a geo field.
Fields
Decay
EXP_DECAY / GAUSS_DECAY / LIN_DECAY decay curve over x.
Fields
x: Box<FormulaExpr>Decaying expression, e.g. a datetime key or $score.
target: Option<Box<FormulaExpr>>Decay origin; None defaults to zero.
Case
CASE WHEN cond THEN then_ ELSE else_ END.
Fields
cond: Box<FilterExpr>Boolean condition, evaluated as a filter.
then_: Box<FormulaExpr>Value produced when the condition holds.
else_: Box<FormulaExpr>Value produced otherwise.
MatchCondition
Inline MATCH(field, values) boolean used as a 0/1 condition.
Datetime
DATETIME('…') — ISO 8601 datetime constant.
DatetimeKey
DATETIME_KEY('field') — payload datetime field read as a datetime.
Trait Implementations§
Source§impl Clone for FormulaExpr
impl Clone for FormulaExpr
Source§fn clone(&self) -> FormulaExpr
fn clone(&self) -> FormulaExpr
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more