# \_bulk API: a field can't be removed unless deleting the document first and then upsert

**URL:** <https://discuss.elastic.co/t/-bulk-api-a-field-cant-be-removed-unless-deleting-the-document-first-and-then-upsert/23074>\
**Category:** Elasticsearch\
**Created:** [April 2, 2015, 9:55pm UTC](https://discuss.elastic.co/t/-bulk-api-a-field-cant-be-removed-unless-deleting-the-document-first-and-then-upsert/23074 "2015-04-02T21:55:58Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Thong\_Bui](https://avatars.discourse-cdn.com/v4/letter/t/d07c76/32.png) [@Thong\_Bui](https://discuss.elastic.co/u/Thong_Bui)\
**Post date:** [April 2, 2015, 9:55pm UTC](https://discuss.elastic.co/t/-bulk-api-a-field-cant-be-removed-unless-deleting-the-document-first-and-then-upsert/23074/1 "2015-04-02T21:55:58Z")

</div>

Hi all,

Here is the scenario:

1. I first populate the data record in Elasticsearch using \_bulk API:

- here is temp.json look like:  
{ update : {"\_id" : "Tra.1111" }}  
{ doc : {"field1":"Test 1", "field2" : "Test 2" }, doc\_as\_upsert : true }

- I then load it using \_bulk api:  
curl -s -XPOST [http://localhost:9200/thong\_test/test/\_bulk](http://localhost:9200/thong_test/test/_bulk) --data-binary  
@temp.json

1. I then want to remove data in field2, but changing temp.json as below  
still leave field2 behind:

{ update : {"\_id" : "Tra.1111" }}  
{ doc : {"field1":"Test 1", }, doc\_as\_upsert : true }

If I delete it first, then it will work:

{ delete: {"\_id" : "Tra.1111" }}  
{ update : {"\_id" : "Tra.1111" }}  
{ doc : {"field1":"Test 1", "field2" : "Test 2" }, doc\_as\_upsert : true }

However, is there a better to remove a field in \_bulk without delete and  
insert the document?

Thanks so much for your help!

Thong Bui

--  
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/6e2640e0-2ad9-45fe-8d2f-9501388f5d05%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/6e2640e0-2ad9-45fe-8d2f-9501388f5d05%40googlegroups.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, 12:21am UTC](https://discuss.elastic.co/t/-bulk-api-a-field-cant-be-removed-unless-deleting-the-document-first-and-then-upsert/23074/2 "2017-07-06T00:21:57Z")

</div>


