How to group same value

Hello. I made a query which is this:

body = {
                    "aggs": {
                        "Group1": {
                            "terms": {
                                "field": "method.keyword",
                                "include": ".*POST.*",
                            },
                            "aggs": {
                                "Group2": {
                                    "terms": {
                                        "field": "contains.keyword",
                                        "size": 11513,

                                    },
                                    "aggs": {
                                        "Group3": {
                                            "terms": {
                                                "field": "page",
                                                "order": {"_key": "desc"},
                                                "size":1

                                            }
                                        }

                                    },"aggs" : {
                "max_page" : { "max" : { "field" : "page" } }
            },
                                }
                            },



                        }

                    }

                }

                res=es.search(index='apilog',body=body)

It returned me this values:

[
  {
    "Group2": {
      "buckets": [
        {
          "doc_count": 114, 
          "key": "xr", 
          "max_page": {
            "value": null
          }
        }, 
        {
          "doc_count": 37, 
          "key": "fluence", 
          "max_page": {
            "value": 8.0
          }
        }, 
        {
          "doc_count": 32, 
          "key": "macit", 
          "max_page": {
            "value": 4.0
          }
        }, 
        {
          "doc_count": 31, 
          "key": "com", 
          "max_page": {
            "value": 3.0
          }
        }, 
        {
          "doc_count": 31, 
          "key": "crypto", 
          "max_page": {
            "value": null
          }
        }, 
        {
          "doc_count": 28, 
          "key": "cross", 
          "max_page": {
            "value": null
          }
        }, 
        {
          "doc_count": 24, 
          "key": "a", 
          "max_page": {
            "value": 16.0
          }
        }, 
        {
          "doc_count": 20, 
          "key": "sleep", 
          "max_page": {
            "value": 19.0
          }
        }, 
        {
          "doc_count": 19, 
          "key": "nfinite", 
          "max_page": {
            "value": 2.0
          }
        }, 
        {
          "doc_count": 15, 
          "key": "neboola", 
          "max_page": {
            "value": null
          }
        }, 
        {
          "doc_count": 15, 
          "key": "scienced", 
          "max_page": {
            "value": 4.0
          }
        }, 
        {
          "doc_count": 15, 
          "key": "velcro", 
          "max_page": {
            "value": 8.0
          }
        }, 
        {
          "doc_count": 14, 
          "key": "ehemp", 
          "max_page": {
            "value": 7.0
          }
        }, 
        {
          "doc_count": 13, 
          "key": "buzzelle", 
          "max_page": {
            "value": null
          }
        }, 

What I want is that I need to group this value by their "value" part. The returned value need to be like: for example for value:4 it must show the key that its value is 4.
What do you recommend me?

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