Top n over Max() aggregation with group by and then return all fields

Hi,
I'm a total newbie to Elasticsearch and hence please ignore if you think my question is very basic.
I've already looked at this post which solves one part of my problem:

What I want is only top n (say top 2) results based on max of Revision number from that post's problem statement.

Reposting the data and expected results here:
Sample Data:
Title | Author | PublishedDate | Revision | Reviewer | ReviewComment
---------------+---------------+------------------------+---------------+---------------+-----------------
The Endgame |Parker |2018-12-04|1 |Martin |not good
The Endgame |Parker |2018-12-14|2 |Henry |passed
I Star Wars |James |2019-02-04|1 |Mary |needs improvement
I wonder why |James |2019-03-04|4 |Jack |awesome!
I wonder why |James |2019-03-04|5 |Jones |not bad

I want top 2 (based on Revision) unique Title+Author as highlighted in bold above.

Found the response from a colleague that worked:

{
    "aggs": {
        "top_n_title": {
            "multi_terms": {
                "terms": [
                    {
                        "field": "Title"
                    },
                    {
                        "field": "Author"
                    }
                ],
                "order": {
                    "max_Revision": "desc"
                },                
                "size": 1000                
            },
            "aggs": {
                "max_Revision": {
                    "max": {
                        "field": "Revision"
                    }
                }
            }
        }
    }
}

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