I am new to elasticsearch and Painless, so need some guidance
I want to update values of Merge_ID in bucket result according to minimum of merge_ID in a bucket group members' and apply that rest of bucket members Merge_id using painless?
POST /index_test1/_update_by_query
{
"aggs": {
"GroupByType": {
"terms": {
"field": "FirstName.first_key"
},
"aggs": {
"Group": {
"top_hits":{
"size":12,
"_source": {
"include": ["Email", "CustomerNo", "FirstName", "LastName", "Phoneno","Merge_ID"]
},
"sort":[{
"CustomerNo.keyword": {
"order": "asc"
}
}]
}
}
}
}
}
,
"size": 0,
"script_fields": {
"my_field_name" : {
"script": {
"lang": "painless",
"source": "int min = min(Merge_ID); ctx._source_Merge_ID=min;"
}
}
}
}
Kindly if someone knows how to do it.