Remove field from a structure

I am using Elasticsearch 6.5.
Let say, that my Elasticsearch document looks like this:

"_source" : {
    "field1" : "val1",
    "field2" : "val2",
    "struct1" : {
      "inner_field1" : "inner val1",
      "inner_field2" : "inner val2",
    }
  }

I would like to delete one of inner fields in this structure.
I tried following code:

POST test_idx1/_doc/1/_update
{
 "script": "ctx._source.remove('struct1.inner_field1');"
}

and the result says updated, but nothing changes.
How to perform such action?

Ok, solved it with following syntax:

POST test_idx1/_doc/1/_update
{
 "script": "ctx._source.struct1.remove('inner_field1');"
}

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