Reputation: 407
I'm trying to update only existing documents in Solr 4.
Suppose I have these documents:
Then I want to add a field, but only for existent documents. So I send these documents to Solr:
The resulting indexed documents I want are:
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:
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:
Any ideas?
Upvotes: 1
Views: 461
Reputation: 210
Your solution of using version:1 is correct. But beware that if you send your atomic updates in a batch then any failure will cause the subsequent updates in the batch to be discarded.
In the example that you have given, id:7 will cause a 409 status code (version conflict) but the documents with id:2 and id:3 should be updated.
Upvotes: 0