You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@solr.apache.org by "mkhludnev (via GitHub)" <gi...@apache.org> on 2023/03/13 08:51:58 UTC

[GitHub] [solr] mkhludnev commented on a diff in pull request #1448: SOLR-16183: XML Loader: support indexing single nested child document

mkhludnev commented on code in PR #1448:
URL: https://github.com/apache/solr/pull/1448#discussion_r1133592521


##########
solr/core/src/java/org/apache/solr/handler/loader/XMLLoader.java:
##########
@@ -332,6 +333,11 @@ public SolrInputDocument readDoc(XMLStreamReader parser) throws XMLStreamExcepti
         } else {
           log.debug(message);
         }
+      } else if (NAME.equals(attrName)) {

Review Comment:
   It always all to specify this attribute for `<doc`, but ignore it then. I can't say it's a blocker, slightly changes behavior, and may create wrong expectation for users.. In doubts.. . 



##########
solr/core/src/java/org/apache/solr/handler/loader/XMLLoader.java:
##########
@@ -416,6 +423,21 @@ public SolrInputDocument readDoc(XMLStreamReader parser) throws XMLStreamExcepti
               doc.addField(name, readDoc(parser));
               break;
             }
+            for (int i = 0; i < parser.getAttributeCount(); i++) {
+              attrName = parser.getAttributeLocalName(i);
+              attrVal = parser.getAttributeValue(i);
+              if (NAME.equals(attrName)) {
+                isSingleLabeledChildDoc = true;
+                doc.addField(attrVal, readDoc(parser));
+                break;

Review Comment:
   another unexpected attribute may hide after the valid `name`, or perhaps (??) it allows to repeat `name` 



##########
solr/core/src/java/org/apache/solr/handler/loader/XMLLoader.java:
##########
@@ -416,6 +423,21 @@ public SolrInputDocument readDoc(XMLStreamReader parser) throws XMLStreamExcepti
               doc.addField(name, readDoc(parser));
               break;
             }
+            for (int i = 0; i < parser.getAttributeCount(); i++) {
+              attrName = parser.getAttributeLocalName(i);
+              attrVal = parser.getAttributeValue(i);
+              if (NAME.equals(attrName)) {
+                isSingleLabeledChildDoc = true;
+                doc.addField(attrVal, readDoc(parser));
+                break;
+              } else {
+                log.warn("XML element <doc> has invalid XML attr: {}", attrName);
+              }
+            }
+            if (isSingleLabeledChildDoc) {
+              isSingleLabeledChildDoc = false;

Review Comment:
   can't we reduce the scope for this var declaring it at line 426 ? 



-- 
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.

To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org