Package org.apache.lucene.expressions.js
package org.apache.lucene.expressions.js
Javascript expressions.
A Javascript expression is a numeric expression specified using an expression syntax that's based on JavaScript expressions. You can construct expressions using:
- Integer, floating point, hex and octal literals
- Arithmetic operators:
+ - * / %
- Bitwise operators:
| & ^ ~ << >> >>>
- Boolean operators (including the ternary operator):
&& || ! ?:
- Comparison operators:
< <= == >= >
- Common mathematic functions:
abs ceil exp floor ln log10 logn max min sqrt pow
- Trigonometric library functions:
acosh acos asinh asin atanh atan atan2 cosh cos sinh sin tanh tan
- Distance functions:
haversin
haversinMeters
- Miscellaneous functions:
min, max
- Arbitrary external variables - see
Bindings
JavaScript order of precedence rules apply for operators. Shortcut evaluation is used for
logical operators—the second argument is only evaluated if the value of the expression cannot be
determined after evaluating the first argument. For example, in the expression a || b
, b
is only evaluated if a is not true.
To compile an expression, use JavascriptCompiler
.
-
ClassDescriptionHelper class holding static methods for js math functionsThis class provides an empty implementation of
JavascriptVisitor
, which can be extended to create a visitor which only needs to handle a subset of the available methods.An expression compiler for javascript expressions.Overrides the ANTLR 4 generated JavascriptLexer to allow for proper error handlingAllows for proper error handling in the ANTLR 4 parserThis interface defines a complete generic visitor for a parse tree produced byJavascriptParser
.A helper to parse the context of a variable name, which is the base variable, followed by the sequence of array (integer or string indexed) and member accesses.Represents what a piece of a variable does.