# Deleting a field / subdocument from ES index document

**URL:** https://discuss.elastic.co/t/deleting-a-field-subdocument-from-es-index-document/18564
**Category:** Elasticsearch
**Created:** [July 9, 2014, 10:46pm UTC](https://discuss.elastic.co/t/deleting-a-field-subdocument-from-es-index-document/18564 "2014-07-09T22:46:51Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Anurag\_Choudhary](https://avatars.discourse-cdn.com/v4/letter/a/6bbea6/32.png) [@Anurag\_Choudhary](https://discuss.elastic.co/u/Anurag_Choudhary)
#### Post date: [July 9, 2014, 10:46pm UTC](https://discuss.elastic.co/t/deleting-a-field-subdocument-from-es-index-document/18564/1 "2014-07-09T22:46:51Z")

</div>

Suppose I have following document indexed in ES

{  
Column1 : "Value1",  
Column2 : "Value2  
}

Later if there is a change in document and Column2 is deleted. How can I  
use the Update API to delete this particular field ? All the examples that  
I found on net talk about adding a new field, or updating value of a field  
in JSON document.

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/850b5eaa-3887-4e04-b042-9ac85faac18e%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/850b5eaa-3887-4e04-b042-9ac85faac18e%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

### Author: ![Glen\_Smith](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/glen_smith/32/111656_2.png) [@Glen\_Smith](https://discuss.elastic.co/u/Glen_Smith)
#### Post date: [July 10, 2014, 3:36am UTC](https://discuss.elastic.co/t/deleting-a-field-subdocument-from-es-index-document/18564/2 "2014-07-10T03:36:38Z")

</div>

You re-index the document by its ID.

On Wednesday, July 9, 2014 6:46:51 PM UTC-4, Anurag Choudhary wrote:

> Suppose I have following document indexed in ES
> 
> {  
> Column1 : "Value1",  
> Column2 : "Value2  
> }
> 
> Later if there is a change in document and Column2 is deleted. How can I  
> use the Update API to delete this particular field ? All the examples that  
> I found on net talk about adding a new field, or updating value of a field  
> in JSON document.

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/ec9ddcc2-b01a-4b6a-add4-46435f6d9703%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/ec9ddcc2-b01a-4b6a-add4-46435f6d9703%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

### Author: ![Anurag\_Choudhary](https://avatars.discourse-cdn.com/v4/letter/a/6bbea6/32.png) [@Anurag\_Choudhary](https://discuss.elastic.co/u/Anurag_Choudhary)
#### Post date: [July 10, 2014, 4:21pm UTC](https://discuss.elastic.co/t/deleting-a-field-subdocument-from-es-index-document/18564/3 "2014-07-10T16:21:55Z")

</div>

Reindex would require the application to get the full new document. Since  
in my case the changes are incremental (like delete a field or add a  
field), I will have to re-read the full contents to reindex.

I found following update operation which can remove a field from the  
document. It uses script to do this. My questions is can this be done  
without script using pure Java API. The reason I am trying to avoid script  
is because it is disabled by default.

We can also remove a field from the document:

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

On Wed, Jul 9, 2014 at 8:36 PM, Glen Smith [glen@smithsrock.com](mailto:glen@smithsrock.com) wrote:

> You re-index the document by its ID.
> 
> On Wednesday, July 9, 2014 6:46:51 PM UTC-4, Anurag Choudhary wrote:
> 
> > Suppose I have following document indexed in ES
> > 
> > {  
> > Column1 : "Value1",  
> > Column2 : "Value2  
> > }
> > 
> > Later if there is a change in document and Column2 is deleted. How can I  
> > use the Update API to delete this particular field ? All the examples that  
> > I found on net talk about adding a new field, or updating value of a field  
> > in JSON document.
> 
> --  
> You received this message because you are subscribed to a topic in the  
> Google Groups "elasticsearch" group.  
> To unsubscribe from this topic, visit  
> [https://groups.google.com/d/topic/elasticsearch/6Xbg7jg\_w14/unsubscribe](https://groups.google.com/d/topic/elasticsearch/6Xbg7jg_w14/unsubscribe).  
> To unsubscribe from this group and all its topics, send an email to  
> [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/ec9ddcc2-b01a-4b6a-add4-46435f6d9703%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/ec9ddcc2-b01a-4b6a-add4-46435f6d9703%40googlegroups.com)  
> [https://groups.google.com/d/msgid/elasticsearch/ec9ddcc2-b01a-4b6a-add4-46435f6d9703%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/ec9ddcc2-b01a-4b6a-add4-46435f6d9703%40googlegroups.com?utm_medium=email&utm_source=footer)  
> .
> 
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CANWBWsXR0vXEWeMSyRuKJWSb%2BH4FYMWruzodkf9SQbXmLFqcgw%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CANWBWsXR0vXEWeMSyRuKJWSb%2BH4FYMWruzodkf9SQbXmLFqcgw%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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 6, 2017, 1:16am UTC](https://discuss.elastic.co/t/deleting-a-field-subdocument-from-es-index-document/18564/4 "2017-07-06T01:16:45Z")

</div>


