Computing return fields with scripting
ElasticSearch allows you to define complex expressions that can be used to return a new calculated field value. These special fields are called script_fields
, and they can be expressed with a script in every available ElasticSearch scripting language.
Getting ready
You will need a working ElasticSearch cluster and an index populated with the script (chapter_06/populate_aggregations.sh
) used in Chapter 6, Aggregations, which is available at https://github.com/aparo/elasticsearch-cookbook-second-edition.
How to do it...
In order to compute return fields with scripting, perform the following steps:
- Return the following script fields:
"my_calc_field"
: This concatenates the text of the"name"
and"description"
fields ...
Get ElasticSearch Cookbook - Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.