My document has a nested structure like this:
PUT /customer/_doc/1
{
"name": "hello",
"body": {
"module": "aa",
"config": "bb"
}
}
Now, I'd like to update body
field to be:
{
"module": "cc",
"args": "dd"
}
Pay attention I need to:
- update the value associated to
module
- remove the
config
field - add an
args
field
I tried to use update API
POST /customer/_update/1
{
"doc": {
"body": {
"module": "cc",
"args": "dd"
}
}
}
It almost works, but the problem is that the config
field is not removed
GET /customer/_doc/1
{
...
"_source" : {
"name" : "hello",
"body" : {
"module" : "cc",
"config" : "bb",
"args" : "dd"
}
}
}
Is the exact merging algorithm used by update API documented somewhere?
Is there a way to achieve this without writing a script?
I don't want to get the document, do the merge and ind it again ( I prefer to use the update API to avoid roundtrips and benefit from auto retry mechanism)