Scripting can be used in aggregations for extending its analytics capabilities in order to change the values used in metric aggregations or to define new rules to create buckets.
Using scripting in aggregations
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.
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 the Kibana console as it provides code completion and better character escaping for Elasticsearch.
To correctly execute the following commands, you...