dsmiley commented on a change in pull request #455: SOLR-12638 URL: https://github.com/apache/lucene-solr/pull/455#discussion_r269403798
########## File path: solr/core/src/java/org/apache/solr/update/processor/DistributedUpdateProcessor.java ########## @@ -645,32 +660,78 @@ boolean getUpdatedDocument(AddUpdateCommand cmd, long versionOnUpdate) throws IO } // full (non-inplace) atomic update + final boolean isDeeplyNestedSchema = req.getSchema().isUsableForChildDocs() && req.getSchema().hasExplicitField(IndexSchema.NEST_PATH_FIELD_NAME); SolrInputDocument sdoc = cmd.getSolrInputDocument(); BytesRef id = cmd.getIndexedId(); - SolrInputDocument oldDoc = RealTimeGetComponent.getInputDocument(cmd.getReq().getCore(), id); + SolrInputDocument nestedDoc = RealTimeGetComponent.getInputDocument(cmd.getReq().getCore(), id, RealTimeGetComponent.Resolution.ROOT_WITH_CHILDREN); - if (oldDoc == null) { - // create a new doc by default if an old one wasn't found - if (versionOnUpdate <= 0) { - oldDoc = new SolrInputDocument(); - } else { + if (nestedDoc == null) { + if (versionOnUpdate > 0) { // could just let the optimistic locking throw the error throw new SolrException(ErrorCode.CONFLICT, "Document not found for update. id=" + cmd.getPrintableId()); } } else { - oldDoc.remove(CommonParams.VERSION_FIELD); + nestedDoc.remove(CommonParams.VERSION_FIELD); } - cmd.solrDoc = docMerger.merge(sdoc, oldDoc); + SolrInputDocument mergedDoc; + if(idField == null || nestedDoc == null) { + // create a new doc by default if an old one wasn't found + mergedDoc = docMerger.merge(sdoc, new SolrInputDocument()); + } else { + if(isDeeplyNestedSchema && nestedDoc.containsKey(IndexSchema.ROOT_FIELD_NAME) && Review comment: this part section is fairly complex. I feel it needs its own method and extra comments on what's happening. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@lucene.apache.org For additional commands, e-mail: dev-h...@lucene.apache.org