Why is the Update API ignoring a passed version number?


(joa) #1

I want to use the versioning feature but I recognized, that the _update
endpoint is not working with the version paramter:

curl -XPOST localhost:9200/myindex/mytype/xJa8LnWvV/_update?version=4 -d '{
"doc": {
"name": "new-name"
}
}'

Updates are performed without any conflict error. Why can't I use
versioning with _update or am I doing something wrong?

When I need to do partial updates with versioning and I do not have the
full doc, do I need to get it first, merge in the updates and do a new
index?

Thanks, Joa

--
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.
For more options, visit https://groups.google.com/groups/opt_out.


(sina.tamanna) #2

Why do you need to specify version=4? Versioning is used internally by
_update and your request should work as intended without explicitly
specifying version.

On Monday, November 4, 2013 9:24:32 PM UTC+1, joa wrote:

I want to use the versioning feature but I recognized, that the _update
endpoint is not working with the version paramter:

curl -XPOST localhost:9200/myindex/mytype/xJa8LnWvV/_update?version=4 -d '{
"doc": {
"name": "new-name"
}
}'

Updates are performed without any conflict error. Why can't I use
versioning with _update or am I doing something wrong?

When I need to do partial updates with versioning and I do not have the
full doc, do I need to get it first, merge in the updates and do a new
index?

Thanks, Joa

--
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.
For more options, visit https://groups.google.com/groups/opt_out.


(joa) #3

I think I need to pass the version parameter to check if the users request
was based on an outdated document?

--
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.
For more options, visit https://groups.google.com/groups/opt_out.


(Luca Cavanna) #4

I don't see any issue at first glance, what you are doing makes perfectly
and is supported by the update api. Then only version 4 of the document
will be updated, otherwise you'll get back an error by default.
What are you seeing instead?

On Tuesday, November 5, 2013 11:25:41 AM UTC+1, joa wrote:

I think I need to pass the version parameter to check if the users request
was based on an outdated document?

--
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.
For more options, visit https://groups.google.com/groups/opt_out.


(joa) #5

Maybe I understood the versioning wrong.
In my index I have a doc (id 123) with a current version of for example 9.
What I thought is, that when I am trying to do an update with:

curl -XPOST localhost:9200/myindex/mytype/123/_update?version=4 -d '{
"doc": {
"name": "new-name"
}
}'

ES would raise an conflict error, cause I am trying to do an update on an
"old document (version 4)" and the document in the index is already at
version 9. Is this how versioning works?

--
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.
For more options, visit https://groups.google.com/groups/opt_out.


(Luca Cavanna) #6

Yes, sounds like you understood it correctly. Can you reproduce a case
where this doesn't work as you expect?

On Tue, Nov 5, 2013 at 2:51 PM, joa joafeldmann@gmail.com wrote:

Maybe I understood the versioning wrong.
In my index I have a doc (id 123) with a current version of for example 9.
What I thought is, that when I am trying to do an update with:

curl -XPOST localhost:9200/myindex/mytype/123/_update?version=4 -d '{
"doc": {
"name": "new-name"
}
}'

ES would raise an conflict error, cause I am trying to do an update on an
"old document (version 4)" and the document in the index is already at
version 9. Is this how versioning works?

--
You received this message because you are subscribed to a topic in the
Google Groups "elasticsearch" group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/elasticsearch/_3kgTHs0oow/unsubscribe.
To unsubscribe from this group and all its topics, send an email to
elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

--
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.
For more options, visit https://groups.google.com/groups/opt_out.


(joa) #7

I've created a gist:

--
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.
For more options, visit https://groups.google.com/groups/opt_out.


(Luca Cavanna) #8

Hey,
you're right, we added support for version in the update api only to
master, which means the coming 1.0:
https://github.com/elasticsearch/elasticsearch/issues/3111 .
We didn't backport to 0.90 the fix because it would have broken backwards
compatibility.
Sorry for the misunderstanding, I'd suggest you to get the document and
apply the changes yourself for now (till 1.0 gets released).

On Tue, Nov 5, 2013 at 3:12 PM, joa joafeldmann@gmail.com wrote:

I've created a gist:
https://gist.github.com/joafeldmann/7319552

--
You received this message because you are subscribed to a topic in the
Google Groups "elasticsearch" group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/elasticsearch/_3kgTHs0oow/unsubscribe.
To unsubscribe from this group and all its topics, send an email to
elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

--
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.
For more options, visit https://groups.google.com/groups/opt_out.


(joa) #9

Ok, thanks Luca!

--
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.
For more options, visit https://groups.google.com/groups/opt_out.


(system) #10