Hi elastic experts, I'm wondering if there is a way to effectively partial update an element in an array field? For example, a document has a commands
field like this:
"commands": [
{
"id": 1000,
"content": "abc",
},
{
"id": 1001,
"content": "bcd",
},
{
"id": 1002,
"content": "cde",
}
]
When updating the index, I can only have the commands that needs to be updated but not all commands. I tried to use update with script, like this:
ctx._source.commands.removeIf(r -> params.commandsToUpdateIds.contains(r.id));
ctx._source.shell.commands.addAll(params.commandsToUpdate);
This doesn't work well when the commands
list is big(more than 3000 commands), I got a lot of version conflict errors, and the update lag is long.
I'm wondering if there is a good way to do partial update for array fields?