Count number of elements in an array


I have a json that contains an array on it. The structure is something like this:

{date:xxx, stock: [ {name: xxx : status:OK}, {name: yyy : status:OK}, {name: zzz : status:KO}, {name: xxz : status:OK},]}

I would like to visualise a bar chart that contains in the Y axis the number of status:OK i have in the array

How can i count the number of occurrences in an array based on a condition? In that example, If i filter by stock.status=OK, it just display a bar with the size 1 instead of 3.


GThe best thing is to solve that at index time.
Otherwise you can use a scripted field with a painless script that computed this at search time.

1 Like

Thanks David. I have it now

The problem im facing now is that it doesnt display a bar when the count is 0. I assume there is an option somewhere, so working on it


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