Indexing of a two documents with same ID at the same time


(Mohammed Ferjani) #1

Hi
I'm using elastic search 5.3 and facing an issue.
We are actually using the index API with optimistic concurrency control and do not see any VersionConflictEngineException in our logs.
To give you more details about the context :
The first index request checks if the document already exists, it doesn't, so we send an index request without version.
The second request (one or few milliseconds later) checks if the document already exists to get its version and send it as a parameter in the new index request, but doesn't find it (that's the point in my opinion), then we send the second request without version parameter, therefore we overwrite the old document (When we check the responses of the two requests the first has "created:true" while the second has"created:false").
For the moment i do not have ideas to workaround this, so i'm gonna have a look at the partial update.
Has anyone faced this problem ?

Any help will be appreciated

Regards,


(David Turner) #2

There is an option to ensure that the document is only created if it does not exist, but to fail if such a document already exists: either ?op_type=create or /_create:

https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-index_.html#operation-type

Hope that helps!


(system) #3

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