# Aggregate document and "cumulate" fields

**URL:** <https://discuss.elastic.co/t/aggregate-document-and-cumulate-fields/323046>\
**Category:** Elasticsearch\
**Created:** [January 12, 2023, 5:00pm UTC](https://discuss.elastic.co/t/aggregate-document-and-cumulate-fields/323046 "2023-01-12T17:00:15Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Fariddev](https://avatars.discourse-cdn.com/v4/letter/f/82dd89/32.png) [@Fariddev](https://discuss.elastic.co/u/Fariddev)\
**Post date:** [January 12, 2023, 5:00pm UTC](https://discuss.elastic.co/t/aggregate-document-and-cumulate-fields/323046/1 "2023-01-12T17:00:15Z")

</div>

Hi,  
i would like to know if it's possible to aggregate documents and cumulate other fields in an array like this :

Documents :

```auto
{
  "type": "fruit",
  "article": "apple",
  "price": 5
}
{
  "type": "fruit",
  "article": "orange",
  "price": 7
}
{
  "type": "clothing",
  "article": "t-shirt",
  "price": 13
}
{
  "type": "clothing",
  "article": "shoes",
  "price": 51
}

```

The expected results :

```auto
{
  "buckets": [
    {
      "type": "fruit",
      "price": [5, 7]
    },
    {
      "type": "clothing",
      "price": [13, 51]
    }
  ]
}

```

Thanks

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [February 9, 2023, 5:00pm UTC](https://discuss.elastic.co/t/aggregate-document-and-cumulate-fields/323046/2 "2023-02-09T17:00:30Z")

</div>

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