Scripted field on Aggregated value

(Krishna Chaitanya) #1

Scripted fields can work on a field or set of fields in the document. I would like to create scripted field on aggregated value.

Say, I have terms aggregation of fieldA with count metric.
I would like to create another field based on the value of count, which says:

if count <= value, scripted_field = 1,
if value1<= count <=value2, scripted_field=2,
how can I achieve this in Kibana?

Also, finally have a data table like this: Is it possible?

 fieldA            Count             scripted_field
  .....            .....                 ......
  .....            .....                 ......

(Lee Drengenberg) #2

Hi Krishna,

Scripted fields work only on values within each individual doc. So if a doc had 3 numeric fields you could use a scripted field to add them together, or average them, or find the min, max, etc. But not across all docs or a set of docs.

But you can also use some scripting within Visualizations in the Advanced JSON field;

I don't know of very many exampels of using it, but here's one;


Issue while plotting percentage in Kibana
(Krishna Chaitanya) #3

Thanks for the response, Lee

(system) #4

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