Skip to content

Commit

Permalink
#1122 Change the versioning scheme used with elastic search
Browse files Browse the repository at this point in the history
There are two configuration options when using Elastic Search's external
Versioning system (see also
https://www.elastic.co/de/blog/elasticsearch-versioning-support )
- reject all index requests that have the same or a smaller version than
the current version of the document
- reject all index requests that have a smaller version than the current
version of the document.

Changed this to option 2.
  • Loading branch information
MPDLTam committed Jul 11, 2019
1 parent 5023d67 commit eff3737
Showing 1 changed file with 13 additions and 2 deletions.
Expand Up @@ -205,9 +205,20 @@ public void deleteBatch(List<?> l) {
* @return
*/
private IndexRequest getIndexRequest(String id, String json, String parent, String type, long timestamp) {
final IndexRequest indexRequest = new IndexRequest();

final IndexRequest indexRequest = new IndexRequest();
indexRequest.index(indexName).id(id).source(json, XContentType.JSON);
indexRequest.versionType(VersionType.EXTERNAL).version(timestamp);

// Add version information (See ticket #1122)
// We can choose here:
// - VersionType.EXTERNAL: Any request to index a document
// that has THE SAME timestamp as the existing
// document will be rejected
// - VersionType.EXTERNAL_GTE: Means that any request to index a document
// that has a timestamp BEFORE the existing document
// will be rejected

indexRequest.versionType(VersionType.EXTERNAL_GTE).version(timestamp);
if (parent != null) {
// indexRequest.parent(parent);
indexRequest.routing(parent);
Expand Down

0 comments on commit eff3737

Please sign in to comment.