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.

(Marius Dragomir) #2

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:

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

And I want to use visualization Horizontal Bar

(Marius Dragomir) #4

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.

(Marius Dragomir) #6

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:


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

(Marius Dragomir) #8

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

(system) #9

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