How do I get the count/size of an array in elasticsearch

elasticsearch, mvel

Solution

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

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

Problem

I want to do a statistical facet on one of my arrays. I hope something like ``` "script" : "doc['myField'].doubleValue ``` or ``` "script" : "doc['myField'].count ``` would work. I havent found any array count method in mvel and I don't even know if accessing the array field in a script actually gives me the array.

Original source