diff --git a/solr/core/src/java/org/apache/solr/handler/UpdateRequestHandler.java b/solr/core/src/java/org/apache/solr/handler/UpdateRequestHandler.java index e8e5f8ee95a..4caaea2169a 100644 --- a/solr/core/src/java/org/apache/solr/handler/UpdateRequestHandler.java +++ b/solr/core/src/java/org/apache/solr/handler/UpdateRequestHandler.java @@ -77,6 +77,12 @@ public class UpdateRequestHandler extends ContentStreamHandlerBase { public void load(SolrQueryRequest req, SolrQueryResponse rsp, ContentStream stream, UpdateRequestProcessor processor) throws Exception { + ContentStreamLoader ldr = pathVsLoaders.get(req.getContext().get("path")); + if(ldr != null){ + ldr.load(req,rsp,stream,processor); + return; + } + String type = req.getParams().get(UpdateParams.ASSUME_CONTENT_TYPE); if(type == null) { type = stream.getContentType(); @@ -134,7 +140,7 @@ public class UpdateRequestHandler extends ContentStreamHandlerBase { invariants = params; } } - + private Map pathVsLoaders = new HashMap<>(); protected Map createDefaultLoaders(NamedList args) { SolrParams p = null; if(args!=null) { @@ -147,7 +153,11 @@ public class UpdateRequestHandler extends ContentStreamHandlerBase { registry.put("application/javabin", new JavabinLoader().init(p) ); registry.put("text/csv", registry.get("application/csv") ); registry.put("text/xml", registry.get("application/xml") ); - registry.put("text/json", registry.get("application/json") ); + registry.put("text/json", registry.get("application/json")); + + pathVsLoaders.put(JSON_PATH,registry.get("application/json")); + pathVsLoaders.put(DOC_PATH,registry.get("application/json")); + pathVsLoaders.put(CSV_PATH,registry.get("application/csv")); return registry; } @@ -166,16 +176,18 @@ public class UpdateRequestHandler extends ContentStreamHandlerBase { public static void addImplicits(List implicits) { implicits.add(getPluginInfo("/update",Collections.emptyMap())); - implicits.add(getPluginInfo("/update/json", singletonMap("update.contentType", "application/json"))); - implicits.add(getPluginInfo("/update/csv", singletonMap("update.contentType", "application/csv"))); - implicits.add(getPluginInfo("/update/json/docs", makeMap("update.contentType", "application/json", "json.command","false"))); + implicits.add(getPluginInfo(JSON_PATH, singletonMap("update.contentType", "application/json"))); + implicits.add(getPluginInfo(CSV_PATH, singletonMap("update.contentType", "application/csv"))); + implicits.add(getPluginInfo(DOC_PATH, makeMap("update.contentType", "application/json", "json.command","false"))); } static PluginInfo getPluginInfo(String name, Map defaults){ Map m = makeMap("name", name, "class", UpdateRequestHandler.class.getName()); return new PluginInfo("requestHandler", m, new NamedList<>( singletonMap("defaults", new NamedList(defaults))) ,null); - } + public static final String DOC_PATH = "/update/json/docs"; + public static final String JSON_PATH = "/update/json"; + public static final String CSV_PATH = "/update/csv"; } 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 32ce31bca90..5e428ef1ab2 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 @@ -113,14 +113,11 @@ public class JsonLoader extends ContentStreamLoader { @SuppressWarnings("fallthrough") void processUpdate() throws IOException { - if("false".equals( req.getParams().get("json.command"))){ - + String path = (String) req.getContext().get("path"); + if(UpdateRequestHandler.DOC_PATH.equals(path) || "false".equals( req.getParams().get("json.command"))){ String split = req.getParams().get("split"); - if(split != null){ - handleSplitMode(split); - } else { - handleStreamingSingleDocs(); - } + String[] f = req.getParams().getParams("f"); + handleSplitMode(split,f); return; } int ev = parser.nextEvent(); @@ -192,9 +189,9 @@ public class JsonLoader extends ContentStreamLoader { } } - private void handleSplitMode(String split) throws IOException { - String[] fields = req.getParams().getParams("f"); - req.getCore().getLatestSchema().getDefaultSearchFieldName(); + private void handleSplitMode(String split, String[] fields) throws IOException { + if(split == null) split = "/"; + if(fields == null || fields.length ==0) fields = new String[]{"/*"}; final boolean echo = "true".equals( req.getParams().get("echo")); JsonRecordReader jsonRecordReader = JsonRecordReader.getInst(split, Arrays.asList(fields)); jsonRecordReader.streamRecords(parser,new JsonRecordReader.Handler() { diff --git a/solr/example/example-schemaless/solr/collection1/conf/schema.xml b/solr/example/example-schemaless/solr/collection1/conf/schema.xml index 1f73d176024..b5f6a936aee 100755 --- a/solr/example/example-schemaless/solr/collection1/conf/schema.xml +++ b/solr/example/example-schemaless/solr/collection1/conf/schema.xml @@ -1049,5 +1049,11 @@ param value --> + + + + + + diff --git a/solr/example/example-schemaless/solr/collection1/conf/solrconfig.xml b/solr/example/example-schemaless/solr/collection1/conf/solrconfig.xml index d46d778a450..440271df6eb 100755 --- a/solr/example/example-schemaless/solr/collection1/conf/solrconfig.xml +++ b/solr/example/example-schemaless/solr/collection1/conf/solrconfig.xml @@ -858,7 +858,6 @@ explicit json true - text @@ -900,7 +899,6 @@ text^0.5 features^1.0 name^1.2 sku^1.5 id^10.0 manu^1.1 cat^1.4 title^10.0 description^5.0 keywords^5.0 author^2.0 resourcename^1.0 - text 100% *:* 10 @@ -971,58 +969,17 @@ spellcheck + + + _text + + - - - - + add-unknown-fields-to-the-schema - - - - - - application/json - add-unknown-fields-to-the-schema - - - - - - - application/json - add-unknown-fields-to-the-schema - false - - + - text - text true @@ -1421,7 +1376,6 @@ explicit - text elevator diff --git a/solr/example/solr/collection1/conf/solrconfig.xml b/solr/example/solr/collection1/conf/solrconfig.xml index 85160fe5dc3..b30dd47e58b 100755 --- a/solr/example/solr/collection1/conf/solrconfig.xml +++ b/solr/example/solr/collection1/conf/solrconfig.xml @@ -826,7 +826,6 @@ explicit 10 - text - - - - - + + + + text + + - text - text true @@ -1606,7 +1597,6 @@ explicit - text elevator