Hi experts. I having problem when i want to sum the max value field.
My query to take the max value field
{
  "size":0,
  "query": {
   "bool":
         {
             "must": [ 
              {"term": {"zone_id" : "1"}}
             ]
         }
},
  
   "aggs": {
  "content_level": {
     "terms": {
        "field": "content_level"
     },
     "aggs":{
     "news_id":{
       "terms": {
       "field": "news_id"
       },
       "aggs": {
       "viewed_count_max": {
        "max": {
         "field":"viewed_count"
        }
       }
       }
     }
     }
  }
   }
}
and the result
   {
    "took": 4,
    "timed_out": false,
    "_shards": {
        "total": 5,
        "successful": 5,
        "failed": 0
    },
    "hits": {
        "total": 4,
        "max_score": 0,
        "hits": []
    },
    "aggregations": {
        "content_level": {
            "doc_count_error_upper_bound": 0,
            "sum_other_doc_count": 0,
            "buckets": [
                {
                    "key": "A",
                    "doc_count": 3,
                    "news_id": {
                        "doc_count_error_upper_bound": 0,
                        "sum_other_doc_count": 0,
                        "buckets": [
                            {
                                "key": "1111",
                                "doc_count": 2,
                                "viewed_count_max": {
                                    "value": 1100
                                }
                            },
                            {
                                "key": "3333",
                                "doc_count": 1,
                                "viewed_count_max": {
                                    "value": 2000
                                }
                            }
                        ]
                    }
                },
                {
                    "key": "B",
                    "doc_count": 1,
                    "news_id": {
                        "doc_count_error_upper_bound": 0,
                        "sum_other_doc_count": 0,
                        "buckets": [
                            {
                                "key": "2222",
                                "doc_count": 1,
                                "viewed_count_max": {
                                    "value": 666
                                }
                            }
                        ]
                    }
                }
            ]
        }
    }
}
anybody can help me sum this viewed_count_max.
Thanks