# Aggregation max additional info

**URL:** <https://discuss.elastic.co/t/aggregation-max-additional-info/252830>\
**Category:** Elasticsearch\
**Created:** [October 21, 2020, 11:17am UTC](https://discuss.elastic.co/t/aggregation-max-additional-info/252830 "2020-10-21T11:17:45Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jogi\_Michal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jogi_michal/32/45613_2.png) [@Jogi\_Michal](https://discuss.elastic.co/u/Jogi_Michal)\
**Post date:** [October 21, 2020, 11:17am UTC](https://discuss.elastic.co/t/aggregation-max-additional-info/252830/1 "2020-10-21T11:17:45Z")

</div>

Hi all,

I have a question if there is a possibility to add some extra fields somehow to the max aggregation result?

My document looks like this:

```auto
{
    "updated": {
      "type": "date"
    },
    "scores": {
      "properties": {
        "score": {
          "properties": {
            "value": {
              "type": "long"
            }
          }
        },
        "type": {
          "type": "keyword"
        }
      },
      "type": "nested"
    },
...
}

```

I want to get max score "values" for each score "type", but I need also "updated" date for each "max" result and I don't know how to do this...

I'm using python elasticsearch-dsl library and I have the first part:

```auto
        query.aggs.bucket(
            'scores',
            'nested',
            path='scores',
        ).bucket(
            'type',
            'terms',
            field='scores.type',
        ).bucket(
            'max_score',
            'max',
            field='scores.score.value',
        )

```

and this is working fine for the aggregation itself but I don't know how to extract "updated" for each max value document.

Appreciate any answer...  
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:** [November 18, 2020, 11:17am UTC](https://discuss.elastic.co/t/aggregation-max-additional-info/252830/2 "2020-11-18T11:17:52Z")

</div>

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