# Why is the Update API ignoring a passed version number?

**URL:** <https://discuss.elastic.co/t/why-is-the-update-api-ignoring-a-passed-version-number/14249>\
**Category:** Elasticsearch\
**Created:** [November 4, 2013, 8:24pm UTC](https://discuss.elastic.co/t/why-is-the-update-api-ignoring-a-passed-version-number/14249 "2013-11-04T20:24:32Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![joa](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/joa/32/1807_2.png) [@joa](https://discuss.elastic.co/u/joa)\
**Post date:** [November 4, 2013, 8:24pm UTC](https://discuss.elastic.co/t/why-is-the-update-api-ignoring-a-passed-version-number/14249/1 "2013-11-04T20:24:32Z")

</div>

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](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![sina\_tamanna](https://avatars.discourse-cdn.com/v4/letter/s/a6a055/32.png) [@sina\_tamanna](https://discuss.elastic.co/u/sina_tamanna)\
**Post date:** [November 5, 2013, 8:27am UTC](https://discuss.elastic.co/t/why-is-the-update-api-ignoring-a-passed-version-number/14249/2 "2013-11-05T08:27:30Z")

</div>

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](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![joa](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/joa/32/1807_2.png) [@joa](https://discuss.elastic.co/u/joa)\
**Post date:** [November 5, 2013, 10:25am UTC](https://discuss.elastic.co/t/why-is-the-update-api-ignoring-a-passed-version-number/14249/3 "2013-11-05T10:25:41Z")

</div>

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](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![javanna](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/javanna/32/4698_2.png) [@javanna](https://discuss.elastic.co/u/javanna)\
**Post date:** [November 5, 2013, 1:39pm UTC](https://discuss.elastic.co/t/why-is-the-update-api-ignoring-a-passed-version-number/14249/4 "2013-11-05T13:39:27Z")

</div>

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](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![joa](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/joa/32/1807_2.png) [@joa](https://discuss.elastic.co/u/joa)\
**Post date:** [November 5, 2013, 1:51pm UTC](https://discuss.elastic.co/t/why-is-the-update-api-ignoring-a-passed-version-number/14249/5 "2013-11-05T13:51:46Z")

</div>

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](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![javanna](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/javanna/32/4698_2.png) [@javanna](https://discuss.elastic.co/u/javanna)\
**Post date:** [November 5, 2013, 1:59pm UTC](https://discuss.elastic.co/t/why-is-the-update-api-ignoring-a-passed-version-number/14249/6 "2013-11-05T13:59:36Z")

</div>

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](mailto: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](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](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> For more options, visit [https://groups.google.com/groups/opt\_out](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](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![joa](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/joa/32/1807_2.png) [@joa](https://discuss.elastic.co/u/joa)\
**Post date:** [November 5, 2013, 2:12pm UTC](https://discuss.elastic.co/t/why-is-the-update-api-ignoring-a-passed-version-number/14249/7 "2013-11-05T14:12:19Z")

</div>

I've created a gist:

> <https://gist.github.com/joafeldmann/7319552>

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![javanna](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/javanna/32/4698_2.png) [@javanna](https://discuss.elastic.co/u/javanna)\
**Post date:** [November 5, 2013, 3:25pm UTC](https://discuss.elastic.co/t/why-is-the-update-api-ignoring-a-passed-version-number/14249/8 "2013-11-05T15:25:01Z")

</div>

Hey,  
you're right, we added support for version in the update api only to  
master, which means the coming 1.0:  
[Update api doesn't support versioning · Issue #3111 · elastic/elasticsearch · GitHub](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](mailto:joafeldmann@gmail.com) wrote:

> I've created a gist:  
> [ES versioning · GitHub](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](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](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> For more options, visit [https://groups.google.com/groups/opt\_out](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](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![joa](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/joa/32/1807_2.png) [@joa](https://discuss.elastic.co/u/joa)\
**Post date:** [November 5, 2013, 4:50pm UTC](https://discuss.elastic.co/t/why-is-the-update-api-ignoring-a-passed-version-number/14249/9 "2013-11-05T16:50:18Z")

</div>

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](mailto:elasticsearch+unsubscribe@googlegroups.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, 2:08am UTC](https://discuss.elastic.co/t/why-is-the-update-api-ignoring-a-passed-version-number/14249/10 "2017-07-06T02:08:45Z")

</div>


