Lucene expressions are a very powerful tool for easy scoring adjustments, without writing custom Java code. The thing that makes Lucene expressions very handy is that using them is very fast-their execution is as fast as native scripts since each expression is compiled to Java bytecode, to achieve native code-like performance, yet they are like dynamic scripts with some limitations. This section will show you what you can do with Lucene expressions.
Lucene provides functionality to compile a JavaScript expression to a Java bytecode. This is how Lucene expressions work and why they are as fast as native Elasticsearch scripts. Lucene expressions can be used in the following Elasticsearch functionalities:
Scripts responsible for sorting
Aggregations that work on numeric fields
In the
function_score
query under thescript_score
queryIn queries using
script_fields
In addition to this, you have to remember that:
Lucene expressions can be only used on numeric fields
Stored...