Python Elasticsearch aggregated query

The request seems correct. The parameter for the request is indeed called aggs, and the ES will return aggregations under aggregations section of the response. Please note that this will be separate from the hits section. So you should have something like this in your ES response:

"aggregations" : {
    "0" : {
      "doc_count_error_upper_bound" : 0,
      "sum_other_doc_count" : 0,
      "buckets" : [ ]
    },
    "1" : {
      "doc_count_error_upper_bound" : 0,
      "sum_other_doc_count" : 0,
      "buckets" : [
        {
          "key" : "...",
          "doc_count" : 2885
        },
        {
          "key" : "...",
          "doc_count" : 2825
        },
        ....
      ]
    }
  }
1 Like