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

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).

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.

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