# Calculate the frequency of the element in the array across different documents

**URL:** <https://discuss.elastic.co/t/calculate-the-frequency-of-the-element-in-the-array-across-different-documents/176718>\
**Category:** Kibana\
**Created:** [April 13, 2019, 4:51am UTC](https://discuss.elastic.co/t/calculate-the-frequency-of-the-element-in-the-array-across-different-documents/176718 "2019-04-13T04:51:18Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![govindarajcs](https://avatars.discourse-cdn.com/v4/letter/g/a5b964/32.png) [@govindarajcs](https://discuss.elastic.co/u/govindarajcs)\
**Post date:** [April 13, 2019, 4:51am UTC](https://discuss.elastic.co/t/calculate-the-frequency-of-the-element-in-the-array-across-different-documents/176718/1 "2019-04-13T04:51:18Z")

</div>

Consider for example,  
My json inputs

**Input**

{

"id" : 38769,

"workers\_list" : [1,2,4,3,1,1,2,3,4,3],

}

{

"id" : 38770,

"workers\_list" : [1,3],

}

{

"id" : 38771,

"workers\_list" : [1,2,4,2,1],

}  
My kibana report either a data table or a bar diagram  
**Output**  
|id|frequency|  
|1|6|  
|2|4|  
|3|4|  
|4|3|

In the sample output for the id - 1 ,frequency is set to 6 (in the first input three 1's and in the second one 1's and in the last input two 1's).

---

<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:** [April 19, 2019, 10:19am UTC](https://discuss.elastic.co/t/calculate-the-frequency-of-the-element-in-the-array-across-different-documents/176718/2 "2019-04-19T10:19:30Z")

</div>

What i would do here is to convert that array to a `text` field which will make that field be analyzed on ingest. This way you can do a count aggregation and till will count all the elements of the array across the documents.

---

<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 17, 2019, 10:20am UTC](https://discuss.elastic.co/t/calculate-the-frequency-of-the-element-in-the-array-across-different-documents/176718/3 "2019-05-17T10:20:16Z")

</div>

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