Need to avoid concurrency issues while updating documents. For example, if two users try to update a document simultaneously (e.g. getting and incrementing a value), both might get the same value and update the same value.
Need to implement optimistic concurrency control to avoid oncurrency issues while updating documents. You can either manually specify the version of the document, in which case ES will not allow to update if your version is the lateast, or you can use the retry_on_conflicts parameter with number of retries to do optimistic concurrency control implicitely.
You should have a working Elasticsearch cluseter and Kibana.
Create an employee document:
You should get back a response with _version = 1. Else delete existing one and create a new record.
Explicit use of _version for optimistic concurrency control
Replace the employee document created with a updates specifying current version:
Documents get updated and version gets updated to 2.
Try executing previous PUT request as is, keeping version=1.
You will get an error of type "version_conflict_engine_exception":
"[_doc]: version conflict, current version  is different than the one provided "
Note: Error will be same even if you do a partial update here using the _update syntax specifying version=1.
Implicit Optimistic Concurrency Control using retry_on_conflicts
We are doing a partial update here using the _update syntax.
Need to use POST, PUT will not work with partial updates.