Aggregation max additional info

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:

{
    "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:

        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

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