Version types EXTERNAL & EXTERNAL_GTE test for version equality in read operation & disallow them in the Update API

Separate version check logic for reads and writes for all version types, which allows different behavior in these cases.
Change `VersionType.EXTERNAL` & `VersionType.EXTERNAL_GTE` to behave the same as `VersionType.INTERNAL` for read operations.
The previous behavior was fit for writes but is useless in reads.

This commit also makes the usage of `EXTERNAL` & `EXTERNAL_GTE` in the update api raise a validation error as it make cause data to
be lost.

Closes #5663 , Closes #5661, Closes #5929
This commit is contained in:
Boaz Leskes 2014-04-23 11:13:25 +02:00
parent 080c4ade25
commit 051beb51a3
22 changed files with 458 additions and 221 deletions

View file

@ -212,3 +212,15 @@ redirected to one of the replicas within that shard id and returns the
result. The replicas are the primary shard and its replicas within that
shard id group. This means that the more replicas we will have, the
better GET scaling we will have.
[float]
[[get-versioning]
=== Versioning support
You can use the `version` parameter to retrieve the document only if
it's current version is equal to the specified one. This behavior is the same
for all version types with the exception of version type `FORCE` which always
retrieves the document.
Note that Elasticsearch do not store older versions of documents. Only the current version can be retrieved.

View file

@ -165,6 +165,14 @@ including:
Support `_source` to return the full updated
source.
`version` & `version_type`:: the Update API uses the Elasticsearch's versioning
support internally to make sure the document doesn't change
during the update. You can use the `version` parameter to specify that the
document should only be updated if it's version matches the one specified.
By setting version type to `force` you can force the new version of the document
after update (use with care! with `force` there is no guaranty the document
didn't change).Version types `external` & `external_gte` are not supported.
And also support `retry_on_conflict` which controls how many times to
retry if there is a version conflict between getting the document and