Using scripts

ElasticSearch has a few functionalities where scripts can be used. You've already seen examples such as updating documents, filtering, and searching. Regardless of the fact that this seems to be advanced, we will take a look at the possibilities given by ElasticSearch. Looking into any request that use scripts, we can spot several fields:

  • script: This field contains the script code.
  • lang: This field informs the engine which language is used. If it is omitted, ElasticSearch assumes mvel.
  • params: This is an object containing parameters. Every defined parameter is available for script by its name. By using parameters, we can write cleaner code. Due to caching, code with parameters performs better than code with embedded constant values. ...

Get ElasticSearch Server now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.