Kibana 5 - Stacked bar plot with a different filter for each color

Hi all,
I'm having a bit of truble trying to get Kibana do a certain bar chart.
In a ridiculous reduction, it looks like this:

My data consists of documents of the following structure:

FULL NAME:  "Michael Jordan"
PROPERTIES: "53Y MALE 198cm" 
DEPARTMENT: Parquet

FULL NAME:  "Sasha Digiulian"
PROPERTIES: "24Y FEMALE 157cm" 
DEPARTMENT: Rock, Ice

FULL NAME:  "Ueli Steck"
PROPERTIES: "40Y MALE 187cm" 
DEPARTMENT: Ice

Eventually, I'd like to display a two-colored bar chart with its X axis the department, and the Y axis being a double bar with one color for the number of males for the department and another color for the number of females.

In this case there will be 3 (double) bars for

[Rock, Ice, Parquet] 

with Y axis being

[(0,1), (1,1), (1,0)]

Now, for each one separately it is easy - define a filter as a query on PROPERTIES, then a (unique) count aggrigation on FULL NAME. But then again - filter is for ALL the plot, what can I do to make a different filter for each color?

Alternatively, I can try to define a scripted field, something like

MALE_NAME: doc['PROPERTIES'].value=~"MALE"?doc['FULL NAME'].value?""

and same for female. But now, scripted fields won't word on strings...

Any Ideas are greatly welcomed. Thanks!

Hi @Uri_Elias

What version of the stack are you on? You can use string expression using Painless (or Groovy) starting with Kibana/ES 5.0 (https://www.elastic.co/guide/en/kibana/5.0/scripted-fields.html)

Btw, don't use Groovy, it's deprecated and will be removed in 6.0, so stick with Painless. Also, make sure to use Kibana 5.1.1 as prior to that version there were some issues filtering and sorting on the more advanced scripted fields. If interested, there is now a new blog on Painless in Kibana scripted fields that has examples and best practices on how to create them: https://www.elastic.co/blog/using-painless-kibana-scripted-fields

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