Use of _version, _primary_term, _seq_no in APIS

It appears _version should not be used at all by REST API clients, as it not guaranteed to be unique.

Can _seq_no, _primary_term be represented as single number to to clients of APIs ? Having to to work with 2 numbers of versioning becomes tedious. Or may be add easy utility class which helps work with the 2 number ? Provided 2 tuples of number it, provides the answers which tuple of _seq_no and _primary_term is higher version ?

As these fields are to be used all the way throughout consumer application code for ensuring optimistic concurrency.

Hi @vptech20nn, it depends what you mean by "number". Each of _seq_no and _primary_term is a 64-bit number so any method for combining them will, in general, need at least 128 bits. Such large numbers are possible, but aren't really common enough to be relied upon in an API. All the general methods I know of to combine pairs of numbers together involve something like squaring, so they would exceed 64 bits after only 2^32 operations, which isn't a lot.

What's the problem with keeping them separate?

We have application code that relies on using the version# comparison, that code was simple with 1 number. Now we need to start using 2 number instead of one, so lot of changes in our code base and APIs we expose and changes to other applications that integrate with our application. Was looking for cleaner way to handle the version to minimize impact of this.

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