Github user dsmiley commented on a diff in the pull request: https://github.com/apache/lucene-solr/pull/395#discussion_r195071571 --- Diff: solr/core/src/java/org/apache/solr/handler/loader/JsonLoader.java --- @@ -570,37 +573,34 @@ private SolrInputDocument parseDoc(int ev) throws IOException { private void parseFieldValue(SolrInputField sif) throws IOException { int ev = parser.nextEvent(); if (ev == JSONParser.OBJECT_START) { - parseExtendedFieldValue(sif, ev); + parseExtendedFieldValue(ev, sif); } else { Object val = parseNormalFieldValue(ev, sif); sif.setValue(val); } } - private void parseExtendedFieldValue(SolrInputField sif, int ev) throws IOException { + private void parseExtendedFieldValue(int ev, SolrInputField sif) throws IOException { assert ev == JSONParser.OBJECT_START; - SolrInputDocument extendedSolrDocument = generateExtendedValueDoc(ev); + SolrInputDocument extendedSolrDocument = parseExtendedValueAsDoc(ev); if (isChildDoc(extendedSolrDocument)) { - SolrInputDocument cDoc = new SolrInputDocument(); - for (Map.Entry<String, SolrInputField> extendedEntry: extendedSolrDocument.entrySet()) { - cDoc.setField(extendedEntry.getKey(), extendedEntry.getValue().getValue()); - } - sif.addValue(cDoc); + sif.addValue(extendedSolrDocument); return; } Object normalFieldValue = null; Map<String, Object> extendedInfo = null; - for (String label: extendedSolrDocument.keySet() ) { - Object fieldVal = extendedSolrDocument.get(label).getValue(); - if ("boost".equals(label)) { + for (SolrInputField field: extendedSolrDocument) { + Object fieldVal = field.getValue(); + String fieldName = field.getName(); --- End diff -- I can understand why you chose the names `fieldName` and `fieldVal` because you are getting this from a SolrInputField. But recognize what's going on here is very unusual ... we are at this point treating this SolrInputDocument as if it were a map and not as a document. Lets add comments about this very explicitly before we loop because this is so strange. Maybe the `field` var could be named `entry`. The _former_ name `label` (or perhaps `extLabel`) var name is much more appropriate as it is _not_ a treated as *field* label/name. Likewise, just choose `val` or `value` or `extValue`. Lets also add a bit of docs to parseExtendedFieldValue explain what this is for, since it's very non-obvious, I think. Essentially, this is a JSON object that is _either_ a child doc, or it's a Map (used for atomic updates), or it's an outdated mechanism to specify the boost which is no longer in Lucene/Solr.
--- --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@lucene.apache.org For additional commands, e-mail: dev-h...@lucene.apache.org