For example: how to get the key (country) of the current bucket in the script after aggregating countries? Hope to give a solution, thank you!
"aggs"{
	"country_group":{
		"terms":{
			"field":"country",
			"size":1000
		},"aggs":{
			"cty": {
          "scripted_metric": {
            "init_script": "",
            "map_script": "",
            "combine_script": "",
            "reduce_script": ""
          }
        }
		}
	}
}