Is there a way to get the key of the current aggregation bucket in script?

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": ""
          }
        }
		}
	}
}

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