I'm trying to update only existing documents in Solr 4.
Suppose I have these documents:
- {id: 1, name:"product 1", price:10}
- {id: 2, name:"product 2", price:15}
- {id: 3, name:"product 3", price:20}
Then I want to add a field, but only for existent documents. So I send these documents to Solr:
- {id: 2, special:true}
- {id: 3, special:true}
- {id: 7, special:true}
The resulting indexed documents I want are:
- {id: 1, name:"product 1", price:10}
- {id: 2, name:"product 2", price:15, special:true}
- {id: 3, name:"product 3", price:20, special:true}
In order to achieve this I'm using the _version_ field (for Atomic Updates, which are already working fine, btw), so my documents for update looks like these:
- {id: 2, special:true, _version_:1}
- {id: 3, special:true, _version_:1}
- {id: 7, special:true, _version_:1}
Using it I expected to get only ids 2 and 3 updated, but I get a 409 Status Code from Solr and none of the docs get updated, because I commit the index after adding all docs.
If I use version=0, then I get something like this:
- {id: 1, name:"product 1", price:10}
- {id: 2, name:"product 2", price:15, special:true}
- {id: 3, name:"product 3", price:20, special:true}
- {id: 7, special:true, _version_:1}
Any ideas?