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 .
             
            
               
               
               
            
            
           
          
            
              
                Alina  
                (Alina)
               
              
                  
                    October 28, 2013,  6:55am
                   
                   
              2 
               
             
            
              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 .
             
            
               
               
               
            
            
           
          
            
              
                jprante  
                (Jörg Prante)
               
              
                  
                    October 28, 2013,  1:22pm
                   
                   
              4 
               
             
            
              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 
{ 
"_index": "test",
 
 
"_type": "type1",
 
 
"_id": "1",
 
 
"_version": 4,
 
 
"exists": true,
 
 
"_source":
 
 
{
 
 
    "field1": "value1"
 
 
}
 
 
} 
 
POST: http://localhost:9200/_bulk  
{ "update" : { "_index" : "test", "_type" : "type1", "_id" : 
"1","_version":1 } } 
{"doc":{ "field1" : "value1" }}
returns
{ 
"took": 60,
 
 
"items":
 
 
[
 
 
    {
 
 
        "update":
 
 
        {
 
 
            "_index": "test",
 
 
            "_type": "type1",
 
 
            "_id": "1",
 
 
            "_version": 5,
 
 
            "ok": true
 
 
        }
 
 
    }
 
 
]
 
 
} 
 
On 28 October 2013 18:52, joergprante@gmail.com  joergprante@gmail.com wrote:
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 .
             
            
               
               
               
            
            
           
          
            
              
                jprante  
                (Jörg Prante)
               
              
                  
                    October 28, 2013,  3:12pm
                   
                   
              6 
               
             
            
              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:
  
  
    
  
  
    
    
      
        opened 12:48PM - 29 May 13 UTC 
      
        
          closed 11:47AM - 20 Jun 13 UTC 
        
      
     
    
        
          >bug
         
        
          v1.0.0.Beta1
         
    
   
 
  
    To reproduce
``` sh
curl -XPOST http://localhost:9200/test/test/1 -d'{
    "fie… ld": "value1"
}'
```
The internal version is now 1.
Now index again:
``` sh
curl -XPOST http://localhost:9200/test/test/1 -d'{
    "field": "value2"
}'
```
Internal version is now 2. 
Try to update using version=1 (should fail)
``` sh
curl -XPOST "http://localhost:9200/test/test/1/_update?version=1" -d'{
    "doc": { "field": "value3" }
}'
```
Which doesn't fail with a version conflict but returns:
``` json
{"ok":true,"_index":"test","_type":"test","_id":"1","_version":3,"_previous_version":2}
```
PS. The java api's UpdateRequestBuilder doesn't have a setVersion method 
   
   
  
    
    
  
  
 
On 28 October 2013 16:12, joergprante@gmail.com  joergprante@gmail.com wrote:
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 .