# Bulk update - insert field if doesn't exist, but don't update

**URL:** https://discuss.elastic.co/t/bulk-update-insert-field-if-doesnt-exist-but-dont-update/59645
**Category:** Elasticsearch
**Created:** [September 2, 2016, 9:46am UTC](https://discuss.elastic.co/t/bulk-update-insert-field-if-doesnt-exist-but-dont-update/59645 "2016-09-02T09:46:46Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![elssar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/elssar/32/9216_2.png) [@elssar](https://discuss.elastic.co/u/elssar)
#### Post date: [September 2, 2016, 9:46am UTC](https://discuss.elastic.co/t/bulk-update-insert-field-if-doesnt-exist-but-dont-update/59645/1 "2016-09-02T09:46:46Z")

</div>

I have an index with existing documents. Some of them have a field missing. Is there a way to do a bulk update where only documents that don't have the field are updated, and documents that have the field are left untouched?

Simply put, given these two documents

```
{"_index":"events","_type":"users","_id":"123","_score":1,"_source":{"signup":"2016-09-01T02:21:08.034","purchase":"2016-09-01T02:39:31.923Z"}}
{"_index":"events","_type":"users","_id":"124","_score":1,"_source":{"signup":"2016-09-01T02:32:23.334"}}

```

If I send the following bulk request -

```
{"update":{"_index":"events","_type":"users","_id":"123"}}
{"doc": {"purchase": "2016-09-01T00:39:31.923Z"}}
{"update":{"_index":"events","_type":"users","_id":"124"}}
{"doc": {"purchase": "2016-09-01T02:43:11.416Z"}}

```

Then the `purchase` field is added to document `124`, but document `123` is not updated

PS - I can't use scripting, its disabled on the cluster.  
PPS - I'm using Elasticsearch version 1.5.2

---

<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:22pm UTC](https://discuss.elastic.co/t/bulk-update-insert-field-if-doesnt-exist-but-dont-update/59645/2 "2017-07-05T22:22:57Z")

</div>


