Painless updating Array of custom objects

Painless updating Array of custom objects

But below script is not working. Please let me know the solution:

code = "ctx._source.attachments.add([" +
""attachmentId" : params.attachmentId," +
""size" : params.size," +
""type" : params.type," +
""file_name" : params.file_name" +
"]);";

Below is working fine:
{
"script": {
"inline": "ctx._source.attachments.add(["first" : params.first, "last" : params.last]);",
"params": {
"first": "123", "last": "456"
}
}
}

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