# Can I delete a field of a doc?

**URL:** https://discuss.elastic.co/t/can-i-delete-a-field-of-a-doc/37553
**Category:** Elasticsearch
**Created:** [December 18, 2015, 9:22am UTC](https://discuss.elastic.co/t/can-i-delete-a-field-of-a-doc/37553 "2015-12-18T09:22:52Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![zaza](https://avatars.discourse-cdn.com/v4/letter/z/e19b73/32.png) [@zaza](https://discuss.elastic.co/u/zaza)
#### Post date: [December 18, 2015, 9:22am UTC](https://discuss.elastic.co/t/can-i-delete-a-field-of-a-doc/37553/1 "2015-12-18T09:22:52Z")

</div>

I want to delete a field of a doc, I tried some ways but failed. Is there a query DSL or api I can use?

---

<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: [December 18, 2015, 9:34am UTC](https://discuss.elastic.co/t/can-i-delete-a-field-of-a-doc/37553/2 "2015-12-18T09:34:15Z")

</div>

Just send a new version of your doc without the field...

---

<div class="post-metadata">

### Author: ![zaza](https://avatars.discourse-cdn.com/v4/letter/z/e19b73/32.png) [@zaza](https://discuss.elastic.co/u/zaza)
#### Post date: [December 18, 2015, 10:08am UTC](https://discuss.elastic.co/t/can-i-delete-a-field-of-a-doc/37553/3 "2015-12-18T10:08:47Z")

</div>

Thanks a lot. If there is no other way to implement it. I will try this way.

---

<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: [December 18, 2015, 10:20am UTC](https://discuss.elastic.co/t/can-i-delete-a-field-of-a-doc/37553/4 "2015-12-18T10:20:13Z")

</div>

It's the easiest way. Is there anything wrong with that method from your point of view?

---

<div class="post-metadata">

### Author: ![nik9000](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nik9000/32/44947_2.png) [@nik9000](https://discuss.elastic.co/u/nik9000)
#### Post date: [December 18, 2015, 3:27pm UTC](https://discuss.elastic.co/t/can-i-delete-a-field-of-a-doc/37553/5 "2015-12-18T15:27:18Z")

</div>

> [@zaza](#):
>
> Thanks a lot. If there is no other way to implement it. I will try this way.

You could use the [update API](https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-update.html) with an update script. This eliminates a round trip at the cost of having to deal with scripting.

---

<div class="post-metadata">

### Author: ![zaza](https://avatars.discourse-cdn.com/v4/letter/z/e19b73/32.png) [@zaza](https://discuss.elastic.co/u/zaza)
#### Post date: [December 24, 2015, 3:27am UTC](https://discuss.elastic.co/t/can-i-delete-a-field-of-a-doc/37553/6 "2015-12-24T03:27:03Z")

</div>

I worry about the conflict of the update, may be some threads update the doc at the same time. But It seems this is the only way. I will fetch the old doc first, remember the old version, and post the new doc without the field I want to remove, and then check the version returned.

---

<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: [December 24, 2015, 8:18am UTC](https://discuss.elastic.co/t/can-i-delete-a-field-of-a-doc/37553/7 "2015-12-24T08:18:31Z")

</div>

You can use versionning: [https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-index\_.html#index-versioning](https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-index_.html#index-versioning)

---

<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 5, 2017, 11:28pm UTC](https://discuss.elastic.co/t/can-i-delete-a-field-of-a-doc/37553/8 "2017-07-05T23:28:54Z")

</div>


