# What is the proper way to handle conflicts in "scripted\_upsert"?

**URL:** https://discuss.elastic.co/t/what-is-the-proper-way-to-handle-conflicts-in-scripted-upsert/101964
**Category:** Elasticsearch
**Created:** [September 27, 2017, 10:11am UTC](https://discuss.elastic.co/t/what-is-the-proper-way-to-handle-conflicts-in-scripted-upsert/101964 "2017-09-27T10:11:29Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![mats990](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mats990/32/37516_2.png) [@mats990](https://discuss.elastic.co/u/mats990)
#### Post date: [September 27, 2017, 10:11am UTC](https://discuss.elastic.co/t/what-is-the-proper-way-to-handle-conflicts-in-scripted-upsert/101964/1 "2017-09-27T10:11:29Z")

</div>

I'm trying to write script using "scripted\_upsert" flag on ES 2.3.4. I'm wondering how should I handle external versions.

- Is it a good practice to verify versions in a script?
- If it's not a good practice, how to verify external versions using scripted\_upsert?
- Can there be any concurrent problems doing it in a script?

For example, my document contains "Ver" field that contains external version. And this is my script: [https://gist.github.com/mats990/39de4f28bd3666374553508ef61cb601](https://gist.github.com/mats990/39de4f28bd3666374553508ef61cb601). Along with other document fields I'm sending "Ver" as a external param to script.  
It seems to me that all of these problems would disappear if I switch to internal version but unfortunately I cannot, and ES is not accepting external version in update API:

> Validation Failed: 1: version type [EXTERNAL] is not supported by the update API;

---

<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 25, 2017, 10:12am UTC](https://discuss.elastic.co/t/what-is-the-proper-way-to-handle-conflicts-in-scripted-upsert/101964/2 "2017-10-25T10:12:15Z")

</div>

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