# Doubt in conflicting version behavior

**URL:** <https://discuss.elastic.co/t/doubt-in-conflicting-version-behavior/166924>\
**Category:** Elasticsearch\
**Created:** [February 4, 2019, 9:21am UTC](https://discuss.elastic.co/t/doubt-in-conflicting-version-behavior/166924 "2019-02-04T09:21:05Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![joaquim](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/joaquim/32/40495_2.png) [@joaquim](https://discuss.elastic.co/u/joaquim)\
**Post date:** [February 4, 2019, 9:21am UTC](https://discuss.elastic.co/t/doubt-in-conflicting-version-behavior/166924/1 "2019-02-04T09:21:05Z")

</div>

Hi,

I'am having conflit's and just wanna know internal behavior of elastic that cause conflit's.

I'am using Java API 5.1.1 for load of documents to elastic.  
I use bulk upsert and after a cicle with update with a script, and receive some conflit's (probably i send request to faster to same index and same document).

I know that version is important, and elastic work with version of a document (I think so), but in which moment elastic request a version of a document to posteriorly update them?

Elastic is assincronous, so suppose that in each request it will be passed on to queue.  
If elastic receive a partial update on a document and a milisecond after receiving another request to set the value of a field based on the script sent and is nothing about the field previous alter, do not need to exist any conflit.

Also I notice that version 6.6 allow persitence on conflit, but do not belive that the team that is inserted will allow migration.

Standard ElasticSearch : 5.6.4  
JAVA : 1.8\_191  
Windows 10 Build 1809

---

<div class="post-metadata">

**Author:** ![DavidTurner](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/davidturner/32/22453_2.png) [@DavidTurner](https://discuss.elastic.co/u/DavidTurner)\
**Post date:** [February 4, 2019, 9:26am UTC](https://discuss.elastic.co/t/doubt-in-conflicting-version-behavior/166924/2 "2019-02-04T09:26:57Z")

</div>

> [@joaquim](#):
>
> If elastic receive a partial update on a document

Elasticsearch does not do partial updates. If you update a document you update the _whole_ document, which increments its version number. This can definitely result in conflicts if you are concurrently updating the same document twice.

> [@joaquim](#):
>
> Elastic is assincronous, so suppose that in each request it will be passed on to queue.

Bulk updates are synchronous: you get a response once all the updates have been applied.

---

<div class="post-metadata">

**Author:** ![joaquim](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/joaquim/32/40495_2.png) [@joaquim](https://discuss.elastic.co/u/joaquim)\
**Post date:** [February 4, 2019, 9:59am UTC](https://discuss.elastic.co/t/doubt-in-conflicting-version-behavior/166924/3 "2019-02-04T09:59:35Z")

</div>

If elastic receive multi-thread synchronous bulk request will conflit, this is my bad. Do you have a opinion on best approach to load elastic ? I have a lot of updates in a close time window on same index and document

---

<div class="post-metadata">

**Author:** ![DavidTurner](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/davidturner/32/22453_2.png) [@DavidTurner](https://discuss.elastic.co/u/DavidTurner)\
**Post date:** [February 4, 2019, 10:49am UTC](https://discuss.elastic.co/t/doubt-in-conflicting-version-behavior/166924/4 "2019-02-04T10:49:46Z")

</div>

> [@joaquim](#):
>
> Do you have a opinion on best approach to load elastic ? I have a lot of updates in a close time window on same index and document

I suggest consolidating the updates to each document on the client side, and then sending batches of these consolidated updates.

---

<div class="post-metadata">

**Author:** ![joaquim](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/joaquim/32/40495_2.png) [@joaquim](https://discuss.elastic.co/u/joaquim)\
**Post date:** [February 4, 2019, 11:07am UTC](https://discuss.elastic.co/t/doubt-in-conflicting-version-behavior/166924/5 "2019-02-04T11:07:30Z")

</div>

Ok, thanks.  
That will be our next step.

Is there a order that elastic follow on Bulk updates? The request are under a ArrayList so order is maintained, my question is elastic will follow that order?

---

<div class="post-metadata">

**Author:** ![DavidTurner](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/davidturner/32/22453_2.png) [@DavidTurner](https://discuss.elastic.co/u/DavidTurner)\
**Post date:** [February 4, 2019, 11:28am UTC](https://discuss.elastic.co/t/doubt-in-conflicting-version-behavior/166924/6 "2019-02-04T11:28:28Z")

</div>

If there are multiple operations on a single document in a bulk request then these are processed in order. There is no ordering guarantee across operations on separate documents. See here:

> [@Order of \_bulk request operations](https://discuss.elastic.co/t/order-of--bulk-request-operations/98124/2):
>
> You can rely on the fact that operations on the same document (same \_index, \_type and \_id) will be in order. However you can't assume anything for documents that have different indices/types/ids.

---

<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:** [March 4, 2019, 11:28am UTC](https://discuss.elastic.co/t/doubt-in-conflicting-version-behavior/166924/7 "2019-03-04T11:28:37Z")

</div>

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