# How to delete a field completely from an index

**URL:** https://discuss.elastic.co/t/how-to-delete-a-field-completely-from-an-index/276893
**Category:** Elasticsearch
**Created:** [June 24, 2021, 8:54am UTC](https://discuss.elastic.co/t/how-to-delete-a-field-completely-from-an-index/276893 "2021-06-24T08:54:36Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![kwoxer](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kwoxer/32/74809_2.png) [@kwoxer](https://discuss.elastic.co/u/kwoxer)
#### Post date: [June 24, 2021, 8:54am UTC](https://discuss.elastic.co/t/how-to-delete-a-field-completely-from-an-index/276893/1 "2021-06-24T08:54:37Z")

</div>

I created some field in the past for testing. Let's take the "STATISTIC-PROCESS-RUNTIME-HOUR" as an example.

So I was able to find a way to remove that field from my index with:

```auto
POST filebeat-7.13.0-2021.05.26-000001/_delete_by_query
{
  "query": {
    "exists": { "field": "STATISTIC-PROCESS-RUNTIME-HOUR" }
  }
}

```

It found the entries and actually deleted them.

And when I now search for it with:

```auto
POST _search
{
  "size": 1,
  "query": {
    "exists": { "field": "STATISTIC-PROCESS-RUNTIME-HOUR" }
  }
}

```

it does not find anything anymore.

So far so good. But it is still in the **Index Patterns**

 ![grafik](https://us1.discourse-cdn.com/elastic/original/3X/a/f/afd793740621a2b0ae6798ae999ad40635418756.png)

How comes?

So how do I properly delete that field?

Btw I for sure refreshed the index, but that didn't change anything

![grafik](https://us1.discourse-cdn.com/elastic/original/3X/a/5/a5151e476a139611cf4474b07c4943eb8dc516ac.png)

---

<div class="post-metadata">

### Author: ![mayya](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mayya/32/83147_2.png) [@mayya](https://discuss.elastic.co/u/mayya)
#### Post date: [June 24, 2021, 10:29pm UTC](https://discuss.elastic.co/t/how-to-delete-a-field-completely-from-an-index/276893/2 "2021-06-24T22:29:30Z")

</div>

There is no way to delete a field from mapping. Even if you delete all documents that contain this field, this field would still be present in mapping and this is where Kibana gets its field suggestions from.

---

<div class="post-metadata">

### Author: ![kwoxer](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kwoxer/32/74809_2.png) [@kwoxer](https://discuss.elastic.co/u/kwoxer)
#### Post date: [June 25, 2021, 4:44am UTC](https://discuss.elastic.co/t/how-to-delete-a-field-completely-from-an-index/276893/3 "2021-06-25T04:44:28Z")

</div>

But what did my command do then?

Ok then the question is how to delete docs with those fields?

And another additional question. When I have a field with multiple types, how can a then make sure the field only has one type?

---

<div class="post-metadata">

### Author: ![Sandeep\_Raju](https://avatars.discourse-cdn.com/v4/letter/s/8797f3/32.png) [@Sandeep\_Raju](https://discuss.elastic.co/u/Sandeep_Raju)
#### Post date: [June 26, 2021, 6:13pm UTC](https://discuss.elastic.co/t/how-to-delete-a-field-completely-from-an-index/276893/4 "2021-06-26T18:13:03Z")

</div>

You need to map carefully when you upload many indices so that there is no clash of field types.  
So you should re-upload these indices and map correctly while uploading.If you dont mind mapping type conflict, you can continue.

---

<div class="post-metadata">

### Author: ![Iker](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/iker/32/91708_2.png) [@Iker](https://discuss.elastic.co/u/Iker)
#### Post date: [June 26, 2021, 8:42pm UTC](https://discuss.elastic.co/t/how-to-delete-a-field-completely-from-an-index/276893/5 "2021-06-26T20:42:37Z")

</div>

If you want to delete all the documents that have the field, you should use a "exist" query and "Delete by query":

> **[Exists query | Elasticsearch Guide \[7.13\] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-exists-query.html)**

> **[Delete by query API | Elasticsearch Guide \[7.13\] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/7.13/docs-delete-by-query.html)**

---

<div class="post-metadata">

### Author: ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)
#### Post date: [June 27, 2021, 10:29pm UTC](https://discuss.elastic.co/t/how-to-delete-a-field-completely-from-an-index/276893/6 "2021-06-27T22:29:07Z")

</div>

The only way to remove the field is to run a reindex into a new index, making sure you don't carry that field over.

---

<div class="post-metadata">

### Author: ![kwoxer](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kwoxer/32/74809_2.png) [@kwoxer](https://discuss.elastic.co/u/kwoxer)
#### Post date: [June 28, 2021, 3:43am UTC](https://discuss.elastic.co/t/how-to-delete-a-field-completely-from-an-index/276893/7 "2021-06-28T03:43:45Z")

</div>

But look, that is exactly what I did.

Ok so the only way is a reindex. But I tried to reindex already and it failed due to memory lack I think. Is there something else I can do now?

---

<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 26, 2021, 3:44am UTC](https://discuss.elastic.co/t/how-to-delete-a-field-completely-from-an-index/276893/8 "2021-07-26T03:44:22Z")

</div>

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