Bulk updates not respecting _version

Hi,

I'm trying to do bulk updates on a index with _version in the conditional
but ES is updating the document even when there is a version conflict:

{"update":{"_index":"urls","_type":"url","_version":1,"_id":"ef2ec2fada4c476c0a7d744236ad9551"}}
{"doc":{"p1":"abc"}}
{"update":{"_index":"urls","_type":"url","_version":1,"_id":"5e343487dc6c0ad2b264ffbaffd946c9"}}
{"doc":{"p2":"xyz"}}

_version is work properly when I update the documents individually.

Regards,
Anand

--
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.

Hello,
I need the same functionality.
Also is there a way to access _version field in script?

Thanks

On Monday, October 28, 2013 7:35:45 AM UTC+2, Anand Nalya wrote:

Hi,

I'm trying to do bulk updates on a index with _version in the conditional
but ES is updating the document even when there is a version conflict:

{"update":{"_index":"urls","_type":"url","_version":1,"_id":"ef2ec2fada4c476c0a7d744236ad9551"}}
{"doc":{"p1":"abc"}}

{"update":{"_index":"urls","_type":"url","_version":1,"_id":"5e343487dc6c0ad2b264ffbaffd946c9"}}
{"doc":{"p2":"xyz"}}

_version is work properly when I update the documents individually.

Regards,
Anand

--
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.

Bulk update logic
@ https://github.com/elasticsearch/elasticsearch/blob/master/src/main/java/org/elasticsearch/action/bulk/BulkRequest.java#L356
is similar to that of delete wrt. version, but still its not working.

This is strange.

On Monday, 28 October 2013 12:25:21 UTC+5:30, Alina wrote:

Hello,
I need the same functionality.
Also is there a way to access _version field in script?

Thanks

On Monday, October 28, 2013 7:35:45 AM UTC+2, Anand Nalya wrote:

Hi,

I'm trying to do bulk updates on a index with _version in the conditional
but ES is updating the document even when there is a version conflict:

{"update":{"_index":"urls","_type":"url","_version":1,"_id":"ef2ec2fada4c476c0a7d744236ad9551"}}
{"doc":{"p1":"abc"}}

{"update":{"_index":"urls","_type":"url","_version":1,"_id":"5e343487dc6c0ad2b264ffbaffd946c9"}}
{"doc":{"p2":"xyz"}}

_version is work properly when I update the documents individually.

Regards,
Anand

--
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.

You apparently use random _id's, so can you please show more information
about how you create a version conflict?

Jörg

--
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.

Following is another test:

GET http://localhost:9200/test/type1/1

  1. {
  2. "_index": "test",
    
  3. "_type": "type1",
    
  4. "_id": "1",
    
  5. "_version": 4,
    
  6. "exists": true,
    
  7. "_source":
    
  8. {
    
  9.     "field1": "value1"
    
  10. }
    
  11. }

POST: http://localhost:9200/_bulk
{ "update" : { "_index" : "test", "_type" : "type1", "_id" :
"1","_version":1 } }
{"doc":{ "field1" : "value1" }}

returns

  1. {
  2. "took": 60,
    
  3. "items":
    
  4. [
    
  5.     {
    
  6.         "update":
    
  7.         {
    
  8.             "_index": "test",
    
  9.             "_type": "type1",
    
  10.             "_id": "1",
    
  11.             "_version": 5,
    
  12.             "ok": true
    
  13.         }
    
  14.     }
    
  15. ]
    
  16. }

On 28 October 2013 18:52, joergprante@gmail.com joergprante@gmail.comwrote:

You apparently use random _id's, so can you please show more information
about how you create a version conflict?

Jörg

--
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/A-Awb64NpTY/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.

Bulk update ignore doc versioning, because update merges old and new
versions.

Example: https://gist.github.com/jprante/7198497

Jörg

--
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.

Support for the version parameter on update / bulk update is only available
in master:

On 28 October 2013 16:12, joergprante@gmail.com joergprante@gmail.comwrote:

Bulk update ignore doc versioning, because update merges old and new
versions.

Example: Bulk updates do not conflict, ignore doc versioning · GitHub

Jörg

--
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.

--
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.

Very interesting. I had synthesized my own update by a combination of
get-by-id, my own additions/deletions to the existing _source, and then an
"index" action with the updated _source along with versioning.

One question about ElasticSearch's "update" action (added since 0.90.1):
Does this actually update the _source?

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