# Delete fields from existing index

**URL:** <https://discuss.elastic.co/t/delete-fields-from-existing-index/133992>\
**Category:** Elasticsearch\
**Created:** [May 31, 2018, 7:33am UTC](https://discuss.elastic.co/t/delete-fields-from-existing-index/133992 "2018-05-31T07:33:16Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![ysree](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ysree/32/31762_2.png) [@ysree](https://discuss.elastic.co/u/ysree)\
**Post date:** [May 31, 2018, 7:33am UTC](https://discuss.elastic.co/t/delete-fields-from-existing-index/133992/1 "2018-05-31T07:33:16Z")

</div>

Hi,

While inserting data to elastic search I got the below error.

{  
"error": {  
"root\_cause": [  
{  
"type": "illegal\_argument\_exception",  
"reason": "Limit of total fields [1000] in index [my\_index] has been exceeded"  
}  
],  
"type": "illegal\_argument\_exception",  
"reason": "Limit of total fields [1000] in index [my\_index] has been exceeded"  
},  
"status": 400  
}

Now I want to remove fields which are created wrongly.

Please provide me the procedure to delete/remove the wrongly created fields from the existing index

Eg:

I want to delete the fields which are highlighted in attached image

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/c/2/c2d69a460d5814de58069d3158bc7a877376daa1.png)

---

<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:** [May 31, 2018, 8:49am UTC](https://discuss.elastic.co/t/delete-fields-from-existing-index/133992/2 "2018-05-31T08:49:04Z")

</div>

You need to reindex for that.

---

<div class="post-metadata">

**Author:** ![ysree](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ysree/32/31762_2.png) [@ysree](https://discuss.elastic.co/u/ysree)\
**Post date:** [May 31, 2018, 8:59am UTC](https://discuss.elastic.co/t/delete-fields-from-existing-index/133992/3 "2018-05-31T08:59:09Z")

</div>

Thanks for the quick reply.

I have few quick questions

1. In general how much time will it take to reindex?
2. Do reindex looses my existing data?

What is the procedure to reindex without having wrongly created fields(multiple fields).

---

<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:** [May 31, 2018, 9:29am UTC](https://discuss.elastic.co/t/delete-fields-from-existing-index/133992/4 "2018-05-31T09:29:42Z")

</div>

1. It depends
2. Reindex means : read from an old index and write a new one so you won't loose your data
3. There is an example in [https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-reindex.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-reindex.html) about removing a field named `foo`.

---

<div class="post-metadata">

**Author:** ![ysree](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ysree/32/31762_2.png) [@ysree](https://discuss.elastic.co/u/ysree)\
**Post date:** [May 31, 2018, 10:20am UTC](https://discuss.elastic.co/t/delete-fields-from-existing-index/133992/5 "2018-05-31T10:20:01Z")

</div>

Below line helps to remove single field. But, I need to remove many such fields. Is there any option in the script to remove multiple fields?

"source": "if (ctx.\_source.foo == 'bar') {ctx.\_version++; ctx.\_source.remove('foo')}"

---

<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:** [May 31, 2018, 10:56am UTC](https://discuss.elastic.co/t/delete-fields-from-existing-index/133992/6 "2018-05-31T10:56:27Z")

</div>

Probably by iteration on a list of fields with a for loop? I'm not a painless script expert so I can't help more here I think.

---

<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:** [June 28, 2018, 10:56am UTC](https://discuss.elastic.co/t/delete-fields-from-existing-index/133992/7 "2018-06-28T10:56:28Z")

</div>

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