florins
florins

Reputation: 1655

Will ElasticSearch merge operation reset the _version number of a document?

I'm using ElasticSearch 6.3 version. In one index, I have observed that the _version number for more than 1000 documents older than 1 month, was greater than 1000. A document contains metadata of an S3 file, such as key and other info,

The _version number of the document matches also the number of versions of S3 file corresponding to document.

My questions are:

  1. How come that such old documents were still keeping the same number of versions without being affected by merge segments operations?

  2. My understanding of the merge segments operation is that it also should reset the _version field to 1. Is that correct?

I look forward for your answers.

Upvotes: 0

Views: 205

Answers (1)

Amit
Amit

Reputation: 32376

First, you need to understand what is merge operation in Elasticsearch:

From the main Elasticsearch doc its not quite clear, but let me add it, that it actually does the hard deletion of old deleted documents, so if a document is updated multiple time then version of its is updated all the time but Elasticsearch just does the soft delete at the time of update and cleans(hard delete) them at the time of segment merging(due to the immutable nature of segments).

Now answering your question is much easy

1.How come that such old documents were still keeping the same number of versions without being affected by merge segments operations?

Ans: These documents might be part of some big segments or due to infrastructure issues merge API is throttling them.

2.My understanding of the merge segments operation is that it also should reset the _version field to 1. Is that correct?

Ans: No merge operation just merge the smaller segments into the big ones and does the hard delete of documents which have been soft deleted and doesn't not change the _version field at all.

Upvotes: 1

Related Questions