I would like to loop over the entries in the map using the Painless script for updating by query...
"script": {
"inline" : "for (int i = 0; i < ctx._source['Items'].length; ++i) { if (ctx._source['Items'][i].id == params.id) { for (entry : params.changes.entrySet()) { ctx._source['Items'][i][entry.getKey()] = entry.getValue() } } }",
"lang" : "painless",
"params": {
"id": "a7f168ce207080641b87098708433c4b",
"changes" : {
"Key0": "val00",
"Key1": "val01",
"Key2": "val02",
"Key3": "val03",
}
}
}
Does not seem to work though. Get error like:
"reason" : "invalid sequence of tokens near [':'].",
Does not seem to like the looping part it looks like
Can 'params' be treated as a Java HashMap? Can 'params' have nested objects within.