dsmiley commented on a change in pull request #455: SOLR-12638
URL: https://github.com/apache/lucene-solr/pull/455#discussion_r270683981
 
 

 ##########
 File path: 
solr/core/src/java/org/apache/solr/update/processor/DistributedUpdateProcessor.java
 ##########
 @@ -663,118 +661,36 @@ boolean getUpdatedDocument(AddUpdateCommand cmd, long 
versionOnUpdate) throws IO
     final boolean isDeeplyNestedSchema = 
req.getSchema().isUsableForChildDocs() && 
req.getSchema().hasExplicitField(IndexSchema.NEST_PATH_FIELD_NAME);
     SolrInputDocument sdoc = cmd.getSolrInputDocument();
     BytesRef id = cmd.getIndexedId();
-    SolrInputDocument completeHierarchy = 
RealTimeGetComponent.getInputDocument(cmd.getReq().getCore(), id, 
RealTimeGetComponent.Resolution.ROOT_WITH_CHILDREN);
+    SolrInputDocument oldRootDocWithChildren = 
RealTimeGetComponent.getInputDocument(cmd.getReq().getCore(), id, 
RealTimeGetComponent.Resolution.ROOT_WITH_CHILDREN);
 
-    if (completeHierarchy == null) {
+    if (oldRootDocWithChildren == 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 {
-      completeHierarchy.remove(CommonParams.VERSION_FIELD);
+      oldRootDocWithChildren.remove(CommonParams.VERSION_FIELD);
     }
 
 
     SolrInputDocument mergedDoc;
-    if(idField == null || completeHierarchy == null) {
+    if(idField == null || oldRootDocWithChildren == null) {
       // create a new doc by default if an old one wasn't found
       mergedDoc = docMerger.merge(sdoc, new SolrInputDocument());
     } else {
-      if(isDeeplyNestedSchema && !isRootDoc(sdoc, completeHierarchy)) {
-        // this is an update and the updated doc is not the root document
+      if(isDeeplyNestedSchema && !docMerger.isRootDoc(sdoc, 
oldRootDocWithChildren)) {
+        // this is an update where the updated doc is not the root document
         SolrInputDocument sdocWithChildren = 
RealTimeGetComponent.getInputDocument(cmd.getReq().getCore(),
             id, RealTimeGetComponent.Resolution.DOC_WITH_CHILDREN);
-        // get path of document to be updated
-        String updatedDocPath = (String) 
sdocWithChildren.getFieldValue(IndexSchema.NEST_PATH_FIELD_NAME);
-        // get the SolrInputField containing the document which the 
AddUpdateCommand updates
-        SolrInputField sifToReplace = getFieldFromHierarchy(completeHierarchy, 
updatedDocPath);
-        // update SolrInputField, either appending or replacing the updated 
document
-        updateDocInSif(sifToReplace, sdocWithChildren, sdoc);
-        mergedDoc = completeHierarchy;
+        mergedDoc = docMerger.mergeNonRoot(sdoc, oldRootDocWithChildren, 
sdocWithChildren);
 
 Review comment:
   `mergeChildDoc` would probably be clearer than `mergeNonRoot`?  It's usually 
clearer to avoid negatives when we can say clearly what it _is_ versus what it 
_is not_.

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to