Painless script for metric fields calculation

Can I use painless script for the metric fields such as sum?
I already have two metric fields: sum(field1) and sum(field2)
I want to create data table in Kibana with one script field value = sum(field1) / sum(field2)
Is there any way to do it with painless script?

Hi Sharon, unfortunately you can't create scripted fields that operate on more than one document.

From our blog post on using Painless in scripted fields:

Scripted fields operate on one Elasticsearch document at a time, but can reference multiple fields in that document. As a result, it is appropriate to use scripted fields to combine or transform fields within a single document, but not perform calculations based on on multiple documents (e.g. time-series math).

Does this answer your question?


1 Like

Thanks! I think for my use case, I will use timelion features. Only problem is that timelion does not allow me to download the data behind it.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.