Github user dsmiley commented on a diff in the pull request:
https://github.com/apache/lucene-solr/pull/395#discussion_r194761077
--- Diff: solr/core/src/java/org/apache/solr/handler/loader/JsonLoader.java
---
@@ -556,82 +572,71 @@ private void parseFieldValue(SolrInputField sif)
throws IOException {
if (ev == JSONParser.OBJECT_START) {
parseExtendedFieldValue(sif, ev);
} else {
- Object val = parseNormalFieldValue(ev, sif.getName());
+ Object val = parseNormalFieldValue(ev, sif);
sif.setValue(val);
}
}
private void parseExtendedFieldValue(SolrInputField sif, int ev)
throws IOException {
assert ev == JSONParser.OBJECT_START;
- Object normalFieldValue = null;
- Map<String, Object> extendedInfo = null;
+ SolrInputDocument extendedSolrDocument =
generateExtendedValueDoc(ev);
- for (; ; ) {
- ev = parser.nextEvent();
- switch (ev) {
- case JSONParser.STRING:
- String label = parser.getString();
- if ("boost".equals(label)) {
- ev = parser.nextEvent();
- if (ev != JSONParser.NUMBER &&
- ev != JSONParser.LONG &&
- ev != JSONParser.BIGNUMBER) {
- throw new
SolrException(SolrException.ErrorCode.BAD_REQUEST, "Boost should have number. "
- + "Unexpected " + JSONParser.getEventString(ev) + " at
[" + parser.getPosition() + "], field=" + sif.getName());
- }
+ if (isChildDoc(extendedSolrDocument)) {
+ SolrInputDocument cDoc = new SolrInputDocument();
+ for (Map.Entry<String, SolrInputField> extendedEntry:
extendedSolrDocument.entrySet()) {
+ cDoc.setField(extendedEntry.getKey(),
extendedEntry.getValue().getValue());
--- End diff --
Why can't you simply do sif.addValue(extendedSolrDocument)? Thus avoiding
the rebuilding of a SolrInputDocument that seems to have no purpose.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]