Count elements within array


(Eviatenne) #1

Hey all,

Let's assume that I have the elasticsearch index "courses", that contains the fields: name (string), tags (array)

Courses:
|name | tags|
|courseA | [java,web]|
|courseB . | [python, web]|
|courseC |[python]|

I would like to create in Kibana a visualize component (for example pie-chart), that will count me the number of courses that appeared for each tag

For example:
web 2
java 1
python 2

Note: I am also fine with splitting the tag array field into two separated fields (tag1, tag2) if that will simplify things...

Please advise :slight_smile:

Thanks, Eviatar


(Brandon Kobel) #2

Hey @eviatenne, if you create a pie chart that uses a terms aggregation on the tags field, you'll get what you're looking for:


(Eviatenne) #3

Thanks, this was exactly what I was looking for!


(system) #4

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