I have some data that I want to sort but when I sort them sort query didn't work very well. So, here what I got after making my query:
"Group3": {
"buckets": [
{
"doc_count": 8,
"key": "1"
},
{
"doc_count": 1,
"key": "11"
},
{
"doc_count": 1,
"key": "15"
},
{
"doc_count": 1,
"key": "18"
},
{
"doc_count": 1,
"key": "8"
}
],
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 0
},
"doc_count": 12,
"key": "mke"
This my query:
"aggs": {
"Group1": {
"terms": {
"field": "method.keyword",
"include": ".*POST.*",
},
"aggs": {
"Group2": {
"terms": {
"field": "keyword.keyword",
"size": 11593,
},
"aggs": {
"Group3": {
"terms": {
"field": "amount.keyword",
"size": 100,
}
}
},
}
},
}
}
What I want is output need to show me the top key value among them, like this:
"Group3": {
"buckets": [
{
"doc_count": 1,
"key": "18"
}
],
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 0
},
"doc_count": 12,
"key": "mke"
How can I do that