⚡ ElasticsearchBook.com is crafted by Jozef Sorocin and powered by:
Scripting enables you to evaluate custom expressions.
As explored in 2. Insertion & Ingestion, we can modify fields.
And as mentioned in Points Closest to the Origin, we can dynamically score documents and calculate new values on-the-fly.
Scripts can be used in various contexts but are leveraged most often:
The default scripting language is [Painless](<https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-scripting-painless.html>)
. Additional lang
plugins enable you to run scripts written in other languages. Everywhere a script can be used, you can include a lang
parameter to specify the language of the script.
~~groovy~~
— slow and discontinuedpainless
— a sandboxed and secure general-purpose language extending a subset of Java’s syntax; offers optional typing through the def
keyword[expression](<https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-scripting-expression.html>)
— Lucene expressions — a sandboxed, javascript-like language used for fast custom ranking and sorting but limited to only numeric, boolean, date, and geo_point fields[mustache](<https://www.elastic.co/guide/en/elasticsearch/reference/current/search-template.html>)
— used in (search) templates. Here's an example.java
— supporting lower-level script engine modules