Thanks Adrien Grand for looking into this.
If I understand the Solr issue correctly, your use-case is to check whether an update can be applied using dv-updates only, or whether it requires an regular update. Do I get it right?
maybe a better way to address this use-case would be to either try the dv-only update and fallback to a regular update if it failed
There are few issues with that approach: 1. When a user's command comes in, it has operations like ("set": 3), or ("inc": 5). At the UpdateProcessor, we resolve it to a merged document (either partial document, or a regular full document) by pulling the last document from the index (or transaction log) to merge the command with that document. We then send the "resolved" document (partial or full) to the DirectUpdateHandler, which performs the IW update. However, by this time, if the IW were to throw an exception for a partial update from the IW.updateDocValues() method, we have already lost the information about the original operation ("set", "inc" etc.), but instead just have the merged values.
2. The second problem is that if we wish to handle the exception for IW.updateDocValues() and decide to fallback on regular update, we could now potentially be merging against a different previous document than the one that was merged with in the failed attempt. 3. The performance cost of a regular update would increase due to merging twice against the previously indexed document.
change the semantics of dv updates to create fields if they did not exist already
I agree that this is the cleanest way forward. From the IndexWriter's API standpoint, I think it would certainly be cleanest if updateDocValues() method were to create non-existent DVs. Till the time we have such functionality in the updateDocValues() method, do you think we could expose the field names through a method marked as internal and/or experimental, with the intention of phasing it out after we have such functionality in IW's updateDocValues()? I think it would be suitable (interim) workaround for applications who find themselves in such a situation.