Skip to content
Permalink
Browse files

#1122 Change the versioning scheme used with elastic search

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...
MPDLbrede committed Jul 11, 2019
1 parent 5023d67 commit eff3737ffb42e94cfd88a45c53241ad6590743af
Showing with 13 additions and 2 deletions.
  1. +13 −2 src/main/java/de/mpg/imeji/logic/search/elasticsearch/ElasticIndexer.java
@@ -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);

0 comments on commit eff3737

Please sign in to comment.
You can’t perform that action at this time.