# Count elements within array

**URL:** <https://discuss.elastic.co/t/count-elements-within-array/139046>\
**Category:** Kibana\
**Created:** [July 8, 2018, 10:08am UTC](https://discuss.elastic.co/t/count-elements-within-array/139046 "2018-07-08T10:08:38Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![eviatenne](https://avatars.discourse-cdn.com/v4/letter/e/bbce88/32.png) [@eviatenne](https://discuss.elastic.co/u/eviatenne)\
**Post date:** [July 8, 2018, 10:08am UTC](https://discuss.elastic.co/t/count-elements-within-array/139046/1 "2018-07-08T10:08:38Z")

</div>

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 🙂

Thanks, Eviatar

---

<div class="post-metadata">

**Author:** ![Brandon\_Kobel](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/brandon_kobel/32/14829_2.png) [@Brandon\_Kobel](https://discuss.elastic.co/u/Brandon_Kobel)\
**Post date:** [July 9, 2018, 12:33pm UTC](https://discuss.elastic.co/t/count-elements-within-array/139046/2 "2018-07-09T12:33:41Z")

</div>

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:

 ![14%20AM](https://us1.discourse-cdn.com/elastic/original/3X/4/1/418dd131463235e3aa6feb0e05163aa537796268.png)

---

<div class="post-metadata">

**Author:** ![eviatenne](https://avatars.discourse-cdn.com/v4/letter/e/bbce88/32.png) [@eviatenne](https://discuss.elastic.co/u/eviatenne)\
**Post date:** [July 9, 2018, 12:51pm UTC](https://discuss.elastic.co/t/count-elements-within-array/139046/3 "2018-07-09T12:51:01Z")

</div>

Thanks, this was exactly what I was looking for!

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [August 6, 2018, 12:51pm UTC](https://discuss.elastic.co/t/count-elements-within-array/139046/4 "2018-08-06T12:51:14Z")

</div>

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