Using updates with external versioning


(David Klotz) #1

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.
To view this discussion on the web visit 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.


(Brian Yoder) #2

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.
To view this discussion on the web visit 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.


(Jörg Prante) #3

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

Jörg

On Wed, Jan 22, 2014 at 12:07 PM, David Klotz david.klotz@fileee.comwrote:

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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/CAKdsXoHY8ZmJP%2BWaCZ0WtN5W26spYwVNpoNYyvQRVs2g3ZPc6g%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


(David Klotz-2) #4

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.
To view this discussion on the web visit 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.


(system) #5