Chapter 8: Scripting in Elasticsearch
Elasticsearch has a powerful way of extending its capabilities by using custom scripts, which can be written in several programming languages. The most common ones are Painless, Express, and Mustache. In this chapter, we will explore how it’s possible to create custom scoring algorithms, specially processed return fields, custom sorting, complex update operations on records, and ingest processors. The scripting concept of Elasticsearch is an advanced stored-procedure system in the NoSQL world; due to this, every advanced user of Elasticsearch should learn how to master it.
Elasticsearch natively provides scripting in Java (that is, Java code compiled in JAR files), Painless, Express, and Mustache; however, a lot of other interesting languages are also available as plugins, such as Kotlin and Velocity. In older Elasticsearch releases, prior to version 5.0, the official scripting language was Groovy. But, for better sandboxing and performance...