# Bulk + doc\_as\_upsert + script

**URL:** <https://discuss.elastic.co/t/bulk-doc-as-upsert-script/14659>\
**Category:** Elasticsearch\
**Created:** [December 2, 2013, 1:47pm UTC](https://discuss.elastic.co/t/bulk-doc-as-upsert-script/14659 "2013-12-02T13:47:20Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![briche\_arnaud](https://avatars.discourse-cdn.com/v4/letter/b/db5fbb/32.png) [@briche\_arnaud](https://discuss.elastic.co/u/briche_arnaud)\
**Post date:** [December 2, 2013, 1:47pm UTC](https://discuss.elastic.co/t/bulk-doc-as-upsert-script/14659/1 "2013-12-02T13:47:20Z")

</div>

Hi,

My use case is the following: I have to perform a bulk update where, either  
the document exists, and I need to execute a script to update a (counter)  
field of this document, or it doesn't, and I just create the document.  
As I understand the update API, I'll need to specify both doc\_as\_upsert  
with the full doc, and script, whith a script to update the counter.  
Is it possible to do so ?

--  
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/128482e4-7e33-4e66-830d-fc9afde9221e%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/128482e4-7e33-4e66-830d-fc9afde9221e%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![briche\_arnaud](https://avatars.discourse-cdn.com/v4/letter/b/db5fbb/32.png) [@briche\_arnaud](https://discuss.elastic.co/u/briche_arnaud)\
**Post date:** [December 3, 2013, 11:22am UTC](https://discuss.elastic.co/t/bulk-doc-as-upsert-script/14659/2 "2013-12-03T11:22:25Z")

</div>

Ok, stupid question. upsert + script do the trick.

--  
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/e8ce68aa-35d7-4576-83b9-dc3319dadb0f%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/e8ce68aa-35d7-4576-83b9-dc3319dadb0f%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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, 2:03am UTC](https://discuss.elastic.co/t/bulk-doc-as-upsert-script/14659/3 "2017-07-06T02:03:38Z")

</div>


