Use aggregation in scripted fields

Hi Guys,
I'm really new to Elasticsearch and Kibana.
At the moment I try to normalize a number field of a document. Therefore I want to use this formula within a scripted field:
normalized_field=(field-min)/(max-min).

So I need to compute min and max aggregation in the script, before compute the formula. Is it possible to store the aggregation result as variable and calculate the formula within the same script?
If yes, then how?

Thanks for your help! :slight_smile:

Unfortunately, that won't be possible until Elasticsearch 2.0 introduces arithmetic functions on top of pipeline aggregation that. This is ES issue #9876, already in ES master, so documentation is available here:
https://www.elastic.co/guide/en/elasticsearch/reference/master/search-aggregations-pipeline-series-arithmetic-aggregation.html

We are still working on a timeline of when that will be integrated into Kibana, so feel free to add an enhancement request here with your use case! https://github.com/elastic/kibana

This sounds very interesting. I'll trace the progress!
Thanks for your advise.