Relation between "_version", "_seq_no" and "_primary_term"

Does "_version" of a document will always map to a unique combination of "_seq_no" and "_primary_term"? Or multiple "_version" of the doc can have same combination of "_seq_no" and "_primary_term"?
From ES 7, the index API no longer takes in the version but instead expects _seq_no and _primary_term to be passed. In our contracts, we were sending the version to our clients and whenever they wanted to update the document they had to send the version back.
Now since that is no more supported, we were thinking of the following approach:

  1. Client gives the version which he wants to edit.
  2. We get the current document and match the version with the one provided. If the version matches, we pick the _seq_no and _primary_term from the current document and issue an edit on the same.
    For the above approach to work, it is essential that every version uniquely maps to _seq_no and _primary_term

I hope that this comment addresses your question, particularly this sentence:

To be clear, the _version field continues not to uniquely identify a particular version of a document; if you need to do this then you should move to using the _seq_no and _primary_term fields.

1 Like

Thanks for the quick reply.

So does _version filed has any significance now? Will it be deprecated in the future versions?

The _version field is still meaningful for external versioning.

Makes sense.
However should the documentation for internal versioning be updated to state it clearly that internal versioning won't work anymore

The doc still says
internal - Only index the document if the given version is identical to the version of the stored document.

Which is not valid anymore. Or is there a way to still issue a write on internal version (if it is acceptable by the developer, even if it doesn't work in corner cases)

That's a good point, those docs do indeed look like they need more work. Would you open an issue on GitHub?

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.