Painless scripting
Painless is a simple, secure scripting language that is available in Elasticsearch by default. It was designed by the Elasticsearch team to be used specifically with Elasticsearch and can safely be used with inline and stored scripting. Its syntax is similar to Groovy, from which it was originally born.
In this recipe, we will see how to create a custom score function in Painless.
Getting ready
You will need an up-and-running Elasticsearch installation, similar to the one that we described in the Downloading and installing Elasticsearch recipe in Chapter 1, Getting Started.
In order to execute the commands, any HTTP client can be used, such as cURL (https://curl.haxx.se/) or Postman (https://www.getpostman.com/). You can use Kibana Console as it provides code completion and better character escaping for Elasticsearch.
To correctly execute the following commands, you will need an index that is populated with the ch07/populate_aggregation.txt
commands...