4

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.

1

1 Answer 1

5

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"
Sign up to request clarification or add additional context in comments.

2 Comments

Ha, I did this and it totally killed my cluster. Maybe there is a way to do this with better performance.
It killed your cluster because it loaded all values of this field into memory and before version 0.90 elasticsearch was using quite inefficient structure to keep values for multi-valued fields in memory. So, you have a few options here: upgrade to 0.90.0.Beta1, use _fields instead of doc if this field is stored or to index the length of the array as another field. The last solution is the best in my opinion.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.