O'Reilly logo

Mastering Elasticsearch 5.x - Third Edition by Bharvi Dixit

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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" | ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required