lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From no...@apache.org
Subject [2/3] lucene-solr:master: SOLR-7123: echo shows wrong output, and added a test for multi level nesting
Date Thu, 09 Jun 2016 06:17:31 GMT
SOLR-7123: echo shows wrong output, and added a test for multi level nesting


Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/84c6e9a4
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/84c6e9a4
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/84c6e9a4

Branch: refs/heads/master
Commit: 84c6e9a477272e71f48b9a8ef040431a0e3f0621
Parents: fdf2bbb
Author: Noble Paul <noble@apache.org>
Authored: Thu Jun 9 11:47:04 2016 +0530
Committer: Noble Paul <noble@apache.org>
Committed: Thu Jun 9 11:47:04 2016 +0530

----------------------------------------------------------------------
 .../org/apache/solr/handler/loader/JsonLoader.java    | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/84c6e9a4/solr/core/src/java/org/apache/solr/handler/loader/JsonLoader.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/handler/loader/JsonLoader.java b/solr/core/src/java/org/apache/solr/handler/loader/JsonLoader.java
index 318f8e6..ab7771a 100644
--- a/solr/core/src/java/org/apache/solr/handler/loader/JsonLoader.java
+++ b/solr/core/src/java/org/apache/solr/handler/loader/JsonLoader.java
@@ -28,6 +28,8 @@ import java.util.List;
 import java.util.Locale;
 import java.util.Map;
 import java.util.UUID;
+import java.util.stream.Collector;
+import java.util.stream.Collectors;
 
 import org.apache.commons.io.IOUtils;
 import org.apache.solr.common.SolrException;
@@ -55,6 +57,7 @@ import org.noggit.ObjectBuilder;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import static java.util.stream.Collectors.toList;
 import static org.apache.solr.common.params.CommonParams.JSON;
 import static org.apache.solr.common.params.CommonParams.PATH;
 
@@ -656,8 +659,15 @@ public class JsonLoader extends ContentStreamLoader {
     }
   }
 
-  private static Map changeChildDoc(Map m) {
-    if (m.containsKey(null)) m.put(CHILD_DOC_KEY, changeChildDoc((Map) m.remove(null)));
+  private static Object changeChildDoc(Object o) {
+    if (o instanceof List) {
+      return ((List) o)
+          .stream()
+          .map(JsonLoader::changeChildDoc)
+          .collect(toList());
+    }
+    Map m = (Map) o;
+    if (m.containsKey(null)) m.put(CHILD_DOC_KEY, changeChildDoc(m.remove(null)));
     return m;
   }
 


Mime
View raw message