# Version conflict when using update\_by\_query

**URL:** <https://discuss.elastic.co/t/version-conflict-when-using-update-by-query/98706>\
**Category:** Elasticsearch\
**Created:** [August 29, 2017, 2:05pm UTC](https://discuss.elastic.co/t/version-conflict-when-using-update-by-query/98706 "2017-08-29T14:05:50Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kornelia\_Watson](https://avatars.discourse-cdn.com/v4/letter/k/a5b964/32.png) [@Kornelia\_Watson](https://discuss.elastic.co/u/Kornelia_Watson)\
**Post date:** [August 29, 2017, 2:05pm UTC](https://discuss.elastic.co/t/version-conflict-when-using-update-by-query/98706/1 "2017-08-29T14:05:51Z")

</div>

Hi all,

I'm trying to use update\_by\_query to update a field in each document but I keep failing due to a version conflict. I don't understand why I am getting version conflicts as I know nothing else is running against the documents I want to update. Any ideas?

The query I'm passing to ES Client in Ruby is:

> ```
> {
> "script": {
> "inline": "ctx._source['salesforce_account_status'] = '#{account[:salesforce_account_status]}'",
> "lang": "painless"
> },
> "query": {
> "term": {
> "account_id": account[:account_id]
> }
> }
> }
> 
> ```

---

<div class="post-metadata">

**Author:** ![geekpete](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/geekpete/32/20409_2.png) [@geekpete](https://discuss.elastic.co/u/geekpete)\
**Post date:** [September 1, 2017, 7:04am UTC](https://discuss.elastic.co/t/version-conflict-when-using-update-by-query/98706/2 "2017-09-01T07:04:25Z")

</div>

Hi Kornelia,

Do you have an example of a conflict error?  
Is the conflict because the version is the same version or that it's trying to use a version that's behind the new version the doc has when it goes to update?

---

<div class="post-metadata">

**Author:** ![geekpete](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/geekpete/32/20409_2.png) [@geekpete](https://discuss.elastic.co/u/geekpete)\
**Post date:** [September 1, 2017, 7:07am UTC](https://discuss.elastic.co/t/version-conflict-when-using-update-by-query/98706/3 "2017-09-01T07:07:47Z")

</div>

If the same version, then it might be that you just have to manually increment it somehow when writing the doc back.

---

<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:** [September 29, 2017, 7:07am UTC](https://discuss.elastic.co/t/version-conflict-when-using-update-by-query/98706/4 "2017-09-29T07:07:49Z")

</div>

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