Apache Lucene open-source search software
SOLR-6365 refactoring and cleanup
Noble Paul8306b8a464dd
diff --git a/solr/core/src/java/org/apache/solr/handler/UpdateRequestHandler.java b/solr/core/src/java/org/apache/solr/handler/UpdateRequestHandler.javaindex 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<String ,ContentStreamLoader> pathVsLoaders = new HashMap<>();protected Map<String,ContentStreamLoader> 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<PluginInfo> 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.javaindex 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.xmlindex 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 @@<str name="paramkey">param value</str></similarity>-->+ <field name="_text" type="text_general" indexed="true" stored="false" multiValued="true"/>+ <field name="_src" type="string" indexed="false" stored="true" multiValued="true"/>++ <copyField source="*" dest="_text"/>++</schema>diff --git a/solr/example/example-schemaless/solr/collection1/conf/solrconfig.xml b/solr/example/example-schemaless/solr/collection1/conf/solrconfig.xmlindex 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 @@<str name="echoParams">explicit</str><str name="wt">json</str><str name="indent">true</str>- <str name="df">text</str></lst></requestHandler>@@ -900,7 +899,6 @@text^0.5 features^1.0 name^1.2 sku^1.5 id^10.0 manu^1.1 cat^1.4title^10.0 description^5.0 keywords^5.0 author^2.0 resourcename^1.0</str>- <str name="df">text</str><str name="mm">100%</str><str name="q.alt">*:*</str><str name="rows">10</str>@@ -971,58 +969,17 @@<str>spellcheck</str></arr></requestHandler>--- <!-- Update Request Handler.-- http://wiki.apache.org/solr/UpdateXmlMessages-- The canonical Request Handler for Modifying the Index through- commands specified using XML, JSON, CSV, or JAVABIN-- Note: Since solr1.1 requestHandlers requires a valid content- type header if posted in the body. For example, curl now- requires: -H 'Content-type:text/xml; charset=utf-8'-- To override the request content type and force a specific- Content-type, use the request parameter:- ?update.contentType=text/csv-- This handler will pick a response format to match the input- if the 'wt' parameter is not explicit- -->- <requestHandler name="/update" class="solr.UpdateRequestHandler">- <!-- See below for information on defining- updateRequestProcessorChains that can be used by name- on each Update Request- -->+ <paramSet path="/update/**,/query,/select,/tvrh,/elevate,/spell,/browse"><lst name="defaults">- <str name="update.chain">add-unknown-fields-to-the-schema</str>+ <str name="df">_text</str></lst>- </requestHandler>+ </paramSet>- <requestHandler name="/update/json" class="solr.UpdateRequestHandler">- <!-- See below for information on defining- updateRequestProcessorChains that can be used by name- on each Update Request- -->+ <paramSet path="/update/**"><lst name="defaults">- <str name="update.contentType">application/json</str><str name="update.chain">add-unknown-fields-to-the-schema</str></lst>- </requestHandler>-- <requestHandler name="/update/json/docs" class="solr.UpdateRequestHandler">- <!-- See below for information on defining- updateRequestProcessorChains that can be used by name- on each Update Request- -->- <lst name="defaults">- <str name="update.contentType">application/json</str>- <str name="update.chain">add-unknown-fields-to-the-schema</str>- <bool name="json.command">false</bool>- </lst>- </requestHandler>+ </paramSet><!-- Solr Cell Update Request Handler@@ -1335,7 +1292,6 @@--><requestHandler name="/spell" class="solr.SearchHandler" startup="lazy"><lst name="defaults">- <str name="df">text</str><!-- Solr will use suggestions from both the 'default' spellcheckerand from the 'wordbreak' spellchecker and combine them.collations (re-written queries) can include a combination of@@ -1372,7 +1328,6 @@--><requestHandler name="/tvrh" class="solr.SearchHandler" startup="lazy"><lst name="defaults">- <str name="df">text</str><bool name="tv">true</bool></lst><arr name="last-components">@@ -1421,7 +1376,6 @@<requestHandler name="/elevate" class="solr.SearchHandler" startup="lazy"><lst name="defaults"><str name="echoParams">explicit</str>- <str name="df">text</str></lst><arr name="last-components"><str>elevator</str>diff --git a/solr/example/solr/collection1/conf/solrconfig.xml b/solr/example/solr/collection1/conf/solrconfig.xmlindex 85160fe5dc3..b30dd47e58b 100755--- a/solr/example/solr/collection1/conf/solrconfig.xml+++ b/solr/example/solr/collection1/conf/solrconfig.xml@@ -826,7 +826,6 @@<lst name="defaults"><str name="echoParams">explicit</str><int name="rows">10</int>- <str name="df">text</str></lst><!-- In addition to defaults, "appends" params can be specifiedto identify values which should be appended to the list of@@ -959,7 +958,6 @@text^0.5 features^1.0 name^1.2 sku^1.5 id^10.0 manu^1.1 cat^1.4title^10.0 description^5.0 keywords^5.0 author^2.0 resourcename^1.0</str>- <str name="df">text</str><str name="mm">100%</str><str name="q.alt">*:*</str><str name="rows">10</str>@@ -1052,18 +1050,13 @@This handler will pick a response format to match the inputif the 'wt' parameter is not explicit-->- <requestHandler name="/update" class="solr.UpdateRequestHandler">- <!-- See below for information on defining- updateRequestProcessorChains that can be used by name- on each Update Request- -->- <!--- <lst name="defaults">- <str name="update.chain">dedupe</str>- </lst>- -->- </requestHandler>-+ <!--<requestHandler name="/update" class="solr.UpdateRequestHandler">+ </requestHandler>-->+ <paramSet path="/update/**,/query,/select,/tvrh,/elevate,/spell,/browse">+ <lst name="defaults">+ <str name="df">text</str>+ </lst>+ </paramSet><!-- The following are implicitly added<requestHandler name="/update/json" class="solr.UpdateRequestHandler"><lst name="defaults">@@ -1403,7 +1396,6 @@--><requestHandler name="/spell" class="solr.SearchHandler" startup="lazy"><lst name="defaults">- <str name="df">text</str><!-- Solr will use suggestions from both the 'default' spellcheckerand from the 'wordbreak' spellchecker and combine them.collations (re-written queries) can include a combination of@@ -1460,7 +1452,6 @@--><requestHandler name="/tvrh" class="solr.SearchHandler" startup="lazy"><lst name="defaults">- <str name="df">text</str><bool name="tv">true</bool></lst><arr name="last-components">@@ -1606,7 +1597,6 @@<requestHandler name="/elevate" class="solr.SearchHandler" startup="lazy"><lst name="defaults"><str name="echoParams">explicit</str>- <str name="df">text</str></lst><arr name="last-components"><str>elevator</str>