# Use of \_version, \_primary\_term, \_seq\_no in APIS

**URL:** https://discuss.elastic.co/t/use-of-version-primary-term-seq-no-in-apis/183972
**Category:** Elasticsearch
**Created:** [June 3, 2019, 1:25pm UTC](https://discuss.elastic.co/t/use-of-version-primary-term-seq-no-in-apis/183972 "2019-06-03T13:25:40Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![vptech20nn](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vptech20nn/32/48264_2.png) [@vptech20nn](https://discuss.elastic.co/u/vptech20nn)
#### Post date: [June 3, 2019, 1:25pm UTC](https://discuss.elastic.co/t/use-of-version-primary-term-seq-no-in-apis/183972/1 "2019-06-03T13:25:40Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![DavidTurner](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/davidturner/32/22453_2.png) [@DavidTurner](https://discuss.elastic.co/u/DavidTurner)
#### Post date: [June 3, 2019, 4:03pm UTC](https://discuss.elastic.co/t/use-of-version-primary-term-seq-no-in-apis/183972/2 "2019-06-03T16:03:20Z")

</div>

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?

---

<div class="post-metadata">

### Author: ![vptech20nn](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vptech20nn/32/48264_2.png) [@vptech20nn](https://discuss.elastic.co/u/vptech20nn)
#### Post date: [June 3, 2019, 5:12pm UTC](https://discuss.elastic.co/t/use-of-version-primary-term-seq-no-in-apis/183972/3 "2019-06-03T17:12:10Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [July 1, 2019, 5:12pm UTC](https://discuss.elastic.co/t/use-of-version-primary-term-seq-no-in-apis/183972/4 "2019-07-01T17:12:28Z")

</div>

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