How to get the count / size of an array in elasticsearch

I want to do a statistical aspect on one of my arrays. Hope something like

"script" : "doc['myField'].doubleValue 

or

 "script" : "doc['myField'].count 

will work. I did not find the method of counting the array in mvel, and I don’t even know if access to the array field in the script really gives me an array.

+4
source share
1 answer

I can have it. It seems I need to count the field inside the array instead of the array itself. It might just be because I have arrays of objects.

 "script" : "doc['arrayField.objectField'].values.length" 
+5
source

All Articles