Elasticsearch scripting
One of the great things in Elasticsearch is its scripting capabilities. In those scenarios where the API is just not enough, Elasticsearch allows you to write your own custom logic in a script. You can use this script for calculating the score, text-based scoring, data filtering, data analysis, and doing partial updates to the documents. Although scripting can be slow in some cases, such as calculating the score for each document, we think that this part of Elasticsearch is important. Scripting is supported in many APIs including search, sorting, aggregations, and document updates.
The syntax
The script follows the following pattern whenever it is used in any Elasticsearch API:
"script": { "lang": "...", "inline" | "id" | "file": "...", "params": { ... } }
Let us understand the script parameters:
The
lang
parameter is the language the script is written in, which defaults topainless
.The
inline | id | file
parameter is the script itself, which may be specified...