Deleting an entry in a map field has no effect

Hi all,

I have a map field, and I'm trying to update it with a script (Painless). when I execute the script with a rest client it works, but not working with the java API (No change, but the result in the UpdateResponse is "UPDATED"). Anyone can help me resolving this:
Elasticsearch 5.2.2 (Tried also on 5.1.1)
--------- Rest Client (Chrome):
POST localhost:9200/context/profile/720c7bc5-9c52-48bd-b281-760f595c6418/_update
BODY :{
"scriptedUpsert": true,
"script": {
"lang": "painless",
"inline": "ctx._source.put("scores", params.scoringValue)",
"params": {
"scoringValue": {
"_i833rilwd": 333
}
}
}
}

--------- Java Client:
String script = "ctx._source.put("scores", params.scoringValue)";

//Map where I remove and put to update
Map<String, Integer> scores = toRemove.getScores();

HashMap<String, Object> scriptParams = new HashMap<>();
scriptParams.put("scoringValue", scores);

Script actualScript = new Script(ScriptType.INLINE, "painless", script, scriptParams);

UpdateResponse resp = client.prepareUpdate(index, itemType, itemId).setScript(actualScript)
.execute()
.get();

Thx in advance for your help :slight_smile:

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