# How to get counts of array item in KQL?

**URL:** <https://discuss.elastic.co/t/how-to-get-counts-of-array-item-in-kql/229802>\
**Category:** Kibana\
**Tags:** kql-kibana-query-language\
**Created:** [April 26, 2020, 3:11am UTC](https://discuss.elastic.co/t/how-to-get-counts-of-array-item-in-kql/229802 "2020-04-26T03:11:46Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![chandler](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/chandler/32/46906_2.png) [@chandler](https://discuss.elastic.co/u/chandler)\
**Post date:** [April 26, 2020, 3:11am UTC](https://discuss.elastic.co/t/how-to-get-counts-of-array-item-in-kql/229802/1 "2020-04-26T03:11:47Z")

</div>

Is there any way to count how many item in the items field ? In the following case is 3.  
I would like to filter docs with more than one item within items. Thanks.

{  
"grocery\_name": "Elastic Eats",  
"items": [  
{  
"name": "peach",  
"stock": "10"  
},  
{  
"name": "carrot",  
"stock": "9"  
},  
{  
"name": "broccoli",  
"stock": "5"  
}  
]  
}

---

<div class="post-metadata">

**Author:** ![Marius\_Dragomir](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/marius_dragomir/32/42087_2.png) [@Marius\_Dragomir](https://discuss.elastic.co/u/Marius_Dragomir)\
**Post date:** [May 3, 2020, 9:48pm UTC](https://discuss.elastic.co/t/how-to-get-counts-of-array-item-in-kql/229802/2 "2020-05-03T21:48:42Z")

</div>

Other than using a scripted field to count it, or by adding a field that has the size at ingest. Other than that, there is no way of doing it in Kibana.

---

<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:** [May 31, 2020, 9:48pm UTC](https://discuss.elastic.co/t/how-to-get-counts-of-array-item-in-kql/229802/3 "2020-05-31T21:48:43Z")

</div>

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