Java High Level REST Client - GetRequest sequence number and primary term

Hi,
I'm using elasticsearch version 7.2.0 and implementing in my application the optimistic concurrency control with sequence number and primary term parameters.
As I understand, before these two parameters were introduiced, optimistic concurrency control was implemented wit hversion parameter.
So, these sequence number and primary term are meant to replace the version parameter (at least for internal versioning) .

Using Java Highl Lever REST client I've noticed in the code and here in the documentation:
https://www.elastic.co/guide/en/elasticsearch/client/java-rest/7.2/java-rest-high-document-get.html
that the GetRequest api still provides a parameter to use old document version parameter, but not for sequence number and primary term.

I think I maybe have misunderstood the differences betweend the old internal version vs. sequence and primary term.

Is this api incomplete or am I missing something?

The response to a "get" request includes the term and sequence number, and "get" requests are realtime, so as soon as a document has been indexed it will be visible to future gets against every in-sync shard copy. If you subsequently get a different version then it must be a later version.

The usual pattern for optimistic concurrency control is to get the latest version of a document (unconditionally) and then update it (conditionally on it not having changed) and for this you do not need a conditional read.

2 Likes

Thanks for the reply, it's clear.

I think I was misleaded by the documentation about version parameter. Seeing that, I was expecting the same behaviour with the new parameters.
I suppose the "old" version parameter is still there to implement optimistic concurrency control with external versioning, is that right?
Also, does in this context document versioning and optimistic concurrency control mean the same thing?

Yes, although I must admit I don't fully understand why we support conditional reads for external versioning either. I will ask around.

Yes, pretty much.

All clear.
Thank you very much.

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