# Update: unset a key

**URL:** https://discuss.elastic.co/t/update-unset-a-key/46506
**Category:** Elasticsearch
**Created:** [April 6, 2016, 9:39am UTC](https://discuss.elastic.co/t/update-unset-a-key/46506 "2016-04-06T09:39:25Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![jbdemonte](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jbdemonte/32/8930_2.png) [@jbdemonte](https://discuss.elastic.co/u/jbdemonte)
#### Post date: [April 6, 2016, 9:39am UTC](https://discuss.elastic.co/t/update-unset-a-key/46506/1 "2016-04-06T09:39:25Z")

</div>

Hello,

Is there a way to unset a key of a document using the update API?

I'm looking for the equivalent of $unset in mongo.

Thanks,  
JB

---

<div class="post-metadata">

### Author: ![danielmitterdorfer](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/danielmitterdorfer/32/110510_2.png) [@danielmitterdorfer](https://discuss.elastic.co/u/danielmitterdorfer)
#### Post date: [April 12, 2016, 7:02am UTC](https://discuss.elastic.co/t/update-unset-a-key/46506/2 "2016-04-12T07:02:02Z")

</div>

Hi,

you can use a [scripted update](https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-update.html#_scripted_updates) and remove a field there.

Here's the example from the docs I am referring to:

```auto
curl -XPOST 'localhost:9200/test/type1/1/_update' -d '{
    "script" : "ctx._source.remove(\"name_of_field\")"
}'

```

Daniel

---

<div class="post-metadata">

### Author: ![jbdemonte](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jbdemonte/32/8930_2.png) [@jbdemonte](https://discuss.elastic.co/u/jbdemonte)
#### Post date: [April 21, 2016, 3:56am UTC](https://discuss.elastic.co/t/update-unset-a-key/46506/3 "2016-04-21T03:56:01Z")

</div>

> [@danielmitterdorfer](#):
>
> remove

Thanks for your help,  
it's really strange that this is not provided as a "classic" feature

---

<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, 10:57pm UTC](https://discuss.elastic.co/t/update-unset-a-key/46506/4 "2017-07-05T22:57:30Z")

</div>


