# Using updates with external versioning

**URL:** <https://discuss.elastic.co/t/using-updates-with-external-versioning/15354>\
**Category:** Elasticsearch\
**Created:** [January 22, 2014, 11:07am UTC](https://discuss.elastic.co/t/using-updates-with-external-versioning/15354 "2014-01-22T11:07:40Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![David\_Klotz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/david_klotz/32/855_2.png) [@David\_Klotz](https://discuss.elastic.co/u/David_Klotz)\
**Post date:** [January 22, 2014, 11:07am UTC](https://discuss.elastic.co/t/using-updates-with-external-versioning/15354/1 "2014-01-22T11:07:40Z")

</div>

Hi,

I am using the "external" version-type for all my documents (they come from  
another primary database and I want to keep the versions between them  
consistent).

Am I right in assuming that this basically means that I can't use the  
\_update API (with a script or partial documents), because it always seems  
to increase the version internally (making the document version go out of  
sync with the version in the primary database)? And I don't see a way of  
specifying a version or version type for update requests (at least in the  
Java API).

It's not critical (i can always do a reindex from the primary DB instead),  
but I thought being able to use the update API could potentially save some  
network roundtrips / performance. But thinking about it I see that getting  
the semantics right in that case (should the update just fail if the  
provided external version does not match? etc.) is probably difficult.

Cheers,  
David

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/9c79d22f-66fa-40b6-966a-92dbd9b69f76%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/9c79d22f-66fa-40b6-966a-92dbd9b69f76%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![brian\_yoder](https://avatars.discourse-cdn.com/v4/letter/b/f1d935/32.png) [@brian\_yoder](https://discuss.elastic.co/u/brian_yoder)\
**Post date:** [January 22, 2014, 3:54pm UTC](https://discuss.elastic.co/t/using-updates-with-external-versioning/15354/2 "2014-01-22T15:54:15Z")

</div>

David,

Using the Java API:

try  
{  
/\* Create using the 3 strings: index, type, and id \*/  
IndexRequestBuilder irb = client.prepareIndex(index, Name, id);

_/_ Set the version number (a long integer value) _/_

- irb.setVersion(versionNumber);\*

_/_ Set external versioning _/_

- irb.setVersionType(VersionType.EXTERNAL);\*

/\* Issue the index request \*/  
IndexResponse response = irb.execute().actionGet();  
}  
catch (Exception e)  
{  
...  
}

Brian

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/ca92bf29-5ed1-42f1-b3c2-f56f1cf62c4b%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/ca92bf29-5ed1-42f1-b3c2-f56f1cf62c4b%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![jprante](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jprante/32/44941_2.png) [@jprante](https://discuss.elastic.co/u/jprante)\
**Post date:** [January 22, 2014, 4:14pm UTC](https://discuss.elastic.co/t/using-updates-with-external-versioning/15354/3 "2014-01-22T16:14:31Z")

</div>

Here is version and version type support for UpdateRequest

[https://github.com/elasticsearch/elasticsearch/blob/master/src/main/java/org/elasticsearch/action/update/UpdateRequest.java#L299](https://github.com/elasticsearch/elasticsearch/blob/master/src/main/java/org/elasticsearch/action/update/UpdateRequest.java#L299)

Jörg

On Wed, Jan 22, 2014 at 12:07 PM, David Klotz [david.klotz@fileee.com](mailto:david.klotz@fileee.com)wrote:

> And I don't see a way of specifying a version or version type for update  
> requests (at least in the Java API).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAKdsXoHY8ZmJP%2BWaCZ0WtN5W26spYwVNpoNYyvQRVs2g3ZPc6g%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAKdsXoHY8ZmJP%2BWaCZ0WtN5W26spYwVNpoNYyvQRVs2g3ZPc6g%40mail.gmail.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![David\_Klotz\_2](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/david_klotz_2/32/855_2.png) [@David\_Klotz\_2](https://discuss.elastic.co/u/David_Klotz_2)\
**Post date:** [January 23, 2014, 9:00am UTC](https://discuss.elastic.co/t/using-updates-with-external-versioning/15354/4 "2014-01-23T09:00:14Z")

</div>

Hi,

this seems to have been added for 1.0.0.RC1, I'm still using 0.90.10,  
but thanks for the hint!

Cheers,  
David

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAF9xhsdZpu\_u9mtkksk5ttLQGiVnvDkZq5%3DYf5Q%3Dk-JE6U-\_KQ%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAF9xhsdZpu_u9mtkksk5ttLQGiVnvDkZq5%3DYf5Q%3Dk-JE6U-_KQ%40mail.gmail.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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 6, 2017, 1:55am UTC](https://discuss.elastic.co/t/using-updates-with-external-versioning/15354/5 "2017-07-06T01:55:11Z")

</div>


