# Help with Scripted\_upsert

**URL:** <https://discuss.elastic.co/t/help-with-scripted-upsert/101543>\
**Category:** Elasticsearch\
**Created:** [September 22, 2017, 11:07pm UTC](https://discuss.elastic.co/t/help-with-scripted-upsert/101543 "2017-09-22T23:07:32Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![karthi01ec](https://avatars.discourse-cdn.com/v4/letter/k/a87d85/32.png) [@karthi01ec](https://discuss.elastic.co/u/karthi01ec)\
**Post date:** [September 22, 2017, 11:07pm UTC](https://discuss.elastic.co/t/help-with-scripted-upsert/101543/1 "2017-09-22T23:07:32Z")

</div>

Hi,

I have a 3 node cluster and i have workflow we i create or update the document . I using the groovy script for both create and update . In the update request i set scripted\_upsert = true.

My understanding is if the document does not exists script will create it as (scripted\_upsert is set to true) . If the document exists it will update it .

I my case , two nodes tried to send the update request concurrently to with scripted\_upsert set to true for same document id . One update request seems to have overwritten the other. In this should't the one request create the document and second one update it (with loosing any data) . I am passing retry\_on\_conflicts as 3 in the update request.

---

<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:** [October 20, 2017, 11:07pm UTC](https://discuss.elastic.co/t/help-with-scripted-upsert/101543/2 "2017-10-20T23:07:33Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
