JSON Input - unique_count

In a visualization I want to calculate in a Json Input: unique_count *5, with groovy

{ "script":
{ "inline": "(unique_count.(doc['f_agenda'].value)*5",
"lang": "groovy" }
}

But groovy is deprecated and I can't do it. I try to do with Painless but I did'nt find the solution.

I try to do with visual buider but I need to show other graphs, and I can't do it with this visualization.

So are you trying to get the value of the unique_count field multiplied by 5? If so, then just using doc['f_agenda'].value * 5 inside a Painless scripted field or script.

If you need anything else calculated using Painless, let us know and we'll try and help.

I want to calculate distinct values of f_agenda and later multiply by 5.
For example:
f_agenda
gomez
garcia
martinez
pepe
garcia

distinct values of f_agenda = 4
and later 4 * 5
Result = 20

And I want to use visualization Horizontal Bar

Is f_agenda an array? If so, you can do the scripted field like this:
doc['f_agenda'].stream().distinct().collect(Collectors.toList()).size() * 5

f_agenda isn't an array.

Then this can't be solved using scripted fields. A scripted field only works in the context of the document, it cannot access values from another document, so you cannot get the unique count over a time period.
What you can do is use Timelion and draw this using the expression:
.es(metric=cardinality:f_agenda).multiply(5)

I can't use Timelion.
I show an example that visualization that I want to get. In this case I want to draw other bar with the unique count of f_agenda'].value * 5

What you want there is not currently possible, there are 2 enhancement requests in the Kibana repo that would help you do it:


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