# Remove field from a structure

**URL:** https://discuss.elastic.co/t/remove-field-from-a-structure/205712
**Category:** Elasticsearch
**Created:** [October 29, 2019, 3:46pm UTC](https://discuss.elastic.co/t/remove-field-from-a-structure/205712 "2019-10-29T15:46:48Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![MMH](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mmh/32/54449_2.png) [@MMH](https://discuss.elastic.co/u/MMH)
#### Post date: [October 29, 2019, 3:46pm UTC](https://discuss.elastic.co/t/remove-field-from-a-structure/205712/1 "2019-10-29T15:46:48Z")

</div>

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

```auto
"_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:

```auto
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?

---

<div class="post-metadata">

### Author: ![MMH](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mmh/32/54449_2.png) [@MMH](https://discuss.elastic.co/u/MMH)
#### Post date: [October 29, 2019, 5:48pm UTC](https://discuss.elastic.co/t/remove-field-from-a-structure/205712/2 "2019-10-29T17:48:19Z")

</div>

Ok, solved it with following syntax:

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

```

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [November 26, 2019, 5:48pm UTC](https://discuss.elastic.co/t/remove-field-from-a-structure/205712/3 "2019-11-26T17:48:25Z")

</div>

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