Sum of each element of array

I'm trying to use an Elasticsearch aggregation to 'merge' an array of integers based on a set of filters. I have documents that look like:

{
  "arr": [5, 4, 3, 2, 1],
  "name": "test"
}
{
  "arr": [4, 3, 2, 1, 0],
  "name": "test"
}
{
  "arr": [1, 0, 0, 0, 0],
  "name": "test"
}

I want to use an aggregation (or some other es method) to return

{
  "arr": [10, 7, 5, 3, 1]
}

The core problem here is that arrays are never guaranteed to be ordered, so each time you got the results they might be different.

can you suggest me a way to achieve this?

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