// This file is autogenerated, DO NOT EDIT
// aggregations/metrics/tophits-aggregation.asciidoc:52

[source, python]
----
resp = client.search(
    index="sales",
    size="0",
    aggs={
        "top_tags": {
            "terms": {
                "field": "type",
                "size": 3
            },
            "aggs": {
                "top_sales_hits": {
                    "top_hits": {
                        "sort": [
                            {
                                "date": {
                                    "order": "desc"
                                }
                            }
                        ],
                        "_source": {
                            "includes": [
                                "date",
                                "price"
                            ]
                        },
                        "size": 1
                    }
                }
            }
        }
    },
)
print(resp)
----
