# Unable to remove field from elastic search

**URL:** <https://discuss.elastic.co/t/unable-to-remove-field-from-elastic-search/188480>\
**Category:** Logstash\
**Created:** [July 2, 2019, 10:39am UTC](https://discuss.elastic.co/t/unable-to-remove-field-from-elastic-search/188480 "2019-07-02T10:39:41Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![bhagmathi](https://avatars.discourse-cdn.com/v4/letter/b/858c86/32.png) [@bhagmathi](https://discuss.elastic.co/u/bhagmathi)\
**Post date:** [July 2, 2019, 10:39am UTC](https://discuss.elastic.co/t/unable-to-remove-field-from-elastic-search/188480/1 "2019-07-02T10:39:42Z")

</div>

## Here is my index

[  
{  
"\_index" : "ind1",  
"\_type" : "doc",  
"\_id" : "ceI6smsB5aL8Y\_rB7r5N",  
"\_score" : 1.0,  
"\_source" : {  
"@timestamp" : "2019-06-27T09:31:08.384Z",  
"id" : 2,  
"name" : "abc",

```
    }
  },
  {
    "_index" : "ind1",
    "_type" : "doc",
    "_id" : "cuI6smsB5aL8Y_rB775e",
    "_score" : 1.0,
    "_source" : {
      "@timestamp" : "2019-06-27T09:31:08.384Z",
      "id" : 1,
      "name" : "xyz",
      
    }
  }

```

## Here is my script

input{  
elasticsearch {  
hosts =\> ["localhost:9200"]  
index =\> "ind1"

}  
}

filter {

mutate {  
remove\_field =\> ["name"]  
}  
}

output {  
elasticsearch {  
hosts =\> ["localhost:9200"]  
action =\> "delete"  
index =\> "ind1"  
document\_type =\> "doc"  
document\_id =\> "%{[@metadata][\_id]}"  
}}

when i run this script , i didn't find any changes in o/p

Can anyone help me with this

---

<div class="post-metadata">

**Author:** ![sjabiulla](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sjabiulla/32/48429_2.png) [@sjabiulla](https://discuss.elastic.co/u/sjabiulla)\
**Post date:** [July 2, 2019, 12:14pm UTC](https://discuss.elastic.co/t/unable-to-remove-field-from-elastic-search/188480/2 "2019-07-02T12:14:49Z")

</div>

> [@bhagmathi](#):
>
> document\_type =\> "doc"

What is the need of adding document\_type in the output config of Elasticsearch ?  
Try removing it once.

---

<div class="post-metadata">

**Author:** ![bhagmathi](https://avatars.discourse-cdn.com/v4/letter/b/858c86/32.png) [@bhagmathi](https://discuss.elastic.co/u/bhagmathi)\
**Post date:** [July 2, 2019, 1:17pm UTC](https://discuss.elastic.co/t/unable-to-remove-field-from-elastic-search/188480/3 "2019-07-02T13:17:40Z")

</div>

@sjabiulla Thanks for your response. But still not working

---

<div class="post-metadata">

**Author:** ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)\
**Post date:** [July 2, 2019, 1:23pm UTC](https://discuss.elastic.co/t/unable-to-remove-field-from-elastic-search/188480/4 "2019-07-02T13:23:25Z")

</div>

[docinfo](https://www.elastic.co/guide/en/logstash/current/plugins-inputs-elasticsearch.html#plugins-inputs-elasticsearch-docinfo) is false by default, so your events will not have the \_id in the @metadata.

---

<div class="post-metadata">

**Author:** ![bhagmathi](https://avatars.discourse-cdn.com/v4/letter/b/858c86/32.png) [@bhagmathi](https://discuss.elastic.co/u/bhagmathi)\
**Post date:** [July 2, 2019, 1:24pm UTC](https://discuss.elastic.co/t/unable-to-remove-field-from-elastic-search/188480/5 "2019-07-02T13:24:55Z")

</div>

@Badger So what should I give in place of document\_id if I don't have any unique field in my docs

---

<div class="post-metadata">

**Author:** ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)\
**Post date:** [July 2, 2019, 2:08pm UTC](https://discuss.elastic.co/t/unable-to-remove-field-from-elastic-search/188480/6 "2019-07-02T14:08:00Z")

</div>

Set 'docinfo =\> true' on the input.

---

<div class="post-metadata">

**Author:** ![bhagmathi](https://avatars.discourse-cdn.com/v4/letter/b/858c86/32.png) [@bhagmathi](https://discuss.elastic.co/u/bhagmathi)\
**Post date:** [July 3, 2019, 6:09am UTC](https://discuss.elastic.co/t/unable-to-remove-field-from-elastic-search/188480/7 "2019-07-03T06:09:29Z")

</div>

@Badger Thanks. It has worked

---

<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:** [July 31, 2019, 6:09am UTC](https://discuss.elastic.co/t/unable-to-remove-field-from-elastic-search/188480/8 "2019-07-31T06:09:32Z")

</div>

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