# Delete field from the index

**URL:** <https://discuss.elastic.co/t/delete-field-from-the-index/126847>\
**Category:** Elasticsearch\
**Created:** [April 5, 2018, 6:16am UTC](https://discuss.elastic.co/t/delete-field-from-the-index/126847 "2018-04-05T06:16:02Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![surajdalvi](https://avatars.discourse-cdn.com/v4/letter/s/85f322/32.png) [@surajdalvi](https://discuss.elastic.co/u/surajdalvi)\
**Post date:** [April 5, 2018, 6:16am UTC](https://discuss.elastic.co/t/delete-field-from-the-index/126847/1 "2018-04-05T06:16:03Z")

</div>

Hi,

I am having one index which consists 20 fields.The index having 2000 documents into it and I want to delete one field from that index. I don't want to update each document.  
Can anyone please tell me how I can remove a field from the index? Is any query for that or any code example for that?

regards,  
Suraj Dalvi

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [April 5, 2018, 7:26am UTC](https://discuss.elastic.co/t/delete-field-from-the-index/126847/2 "2018-04-05T07:26:21Z")

</div>

You can do probably a update by query with a script?  
Not that "removing" a field does not remove the field from the mapping.

Anyway for 2000 documents it will be much much much faster, elegant, straightforward to just reindex in a new index.

---

<div class="post-metadata">

**Author:** ![surajdalvi](https://avatars.discourse-cdn.com/v4/letter/s/85f322/32.png) [@surajdalvi](https://discuss.elastic.co/u/surajdalvi)\
**Post date:** [April 9, 2018, 9:24am UTC](https://discuss.elastic.co/t/delete-field-from-the-index/126847/3 "2018-04-09T09:24:13Z")

</div>

Hi David,  
Thanks for your reply, I want to delete a field from all documents which is a part of an array and I don't know the index of the field in that array. So how I delete such a field from all documents by using a script.  
Please check following example:  
[{  
"name":"test",  
"value":"John"  
},{  
"name":"test2",  
"value":"Ram"  
}]

Here I want to delete field with the name is " **test**"  
Can you please help me into this?

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [April 9, 2018, 9:46am UTC](https://discuss.elastic.co/t/delete-field-from-the-index/126847/4 "2018-04-09T09:46:39Z")

</div>

I'm not a painless user TBH so I don't think i can help.  
But I'd recommend reindexing anyway. That will be much easier IMO.

---

<div class="post-metadata">

**Author:** ![Deepak\_r\_kiran](https://avatars.discourse-cdn.com/v4/letter/d/ecccb3/32.png) [@Deepak\_r\_kiran](https://discuss.elastic.co/u/Deepak_r_kiran)\
**Post date:** [April 9, 2018, 9:56am UTC](https://discuss.elastic.co/t/delete-field-from-the-index/126847/5 "2018-04-09T09:56:50Z")

</div>

David is right, Reindex is better approach.

---

<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:** [May 7, 2018, 9:57am UTC](https://discuss.elastic.co/t/delete-field-from-the-index/126847/6 "2018-05-07T09:57:21Z")

</div>

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