You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by no...@apache.org on 2014/09/04 02:16:32 UTC

svn commit: r1622384 - in /lucene/dev/trunk/solr: core/src/java/org/apache/solr/handler/ core/src/java/org/apache/solr/handler/loader/ example/example-schemaless/solr/collection1/conf/ example/solr/collection1/conf/

Author: noble
Date: Thu Sep  4 00:16:31 2014
New Revision: 1622384

URL: http://svn.apache.org/r1622384
Log:
SOLR-6365 refactoring and cleanup

Modified:
    lucene/dev/trunk/solr/core/src/java/org/apache/solr/handler/UpdateRequestHandler.java
    lucene/dev/trunk/solr/core/src/java/org/apache/solr/handler/loader/JsonLoader.java
    lucene/dev/trunk/solr/example/example-schemaless/solr/collection1/conf/schema.xml
    lucene/dev/trunk/solr/example/example-schemaless/solr/collection1/conf/solrconfig.xml
    lucene/dev/trunk/solr/example/solr/collection1/conf/solrconfig.xml

Modified: lucene/dev/trunk/solr/core/src/java/org/apache/solr/handler/UpdateRequestHandler.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/java/org/apache/solr/handler/UpdateRequestHandler.java?rev=1622384&r1=1622383&r2=1622384&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/java/org/apache/solr/handler/UpdateRequestHandler.java (original)
+++ lucene/dev/trunk/solr/core/src/java/org/apache/solr/handler/UpdateRequestHandler.java Thu Sep  4 00:16:31 2014
@@ -77,6 +77,12 @@ public class UpdateRequestHandler extend
     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 extend
       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 extend
     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 extend
 
   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";
 
 }
 

Modified: lucene/dev/trunk/solr/core/src/java/org/apache/solr/handler/loader/JsonLoader.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/java/org/apache/solr/handler/loader/JsonLoader.java?rev=1622384&r1=1622383&r2=1622384&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/java/org/apache/solr/handler/loader/JsonLoader.java (original)
+++ lucene/dev/trunk/solr/core/src/java/org/apache/solr/handler/loader/JsonLoader.java Thu Sep  4 00:16:31 2014
@@ -113,14 +113,11 @@ public class JsonLoader extends ContentS
     @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 ContentS
       }
     }
 
-    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() {

Modified: lucene/dev/trunk/solr/example/example-schemaless/solr/collection1/conf/schema.xml
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/example/example-schemaless/solr/collection1/conf/schema.xml?rev=1622384&r1=1622383&r2=1622384&view=diff
==============================================================================
--- lucene/dev/trunk/solr/example/example-schemaless/solr/collection1/conf/schema.xml (original)
+++ lucene/dev/trunk/solr/example/example-schemaless/solr/collection1/conf/schema.xml Thu Sep  4 00:16:31 2014
@@ -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>

Modified: lucene/dev/trunk/solr/example/example-schemaless/solr/collection1/conf/solrconfig.xml
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/example/example-schemaless/solr/collection1/conf/solrconfig.xml?rev=1622384&r1=1622383&r2=1622384&view=diff
==============================================================================
--- lucene/dev/trunk/solr/example/example-schemaless/solr/collection1/conf/solrconfig.xml (original)
+++ lucene/dev/trunk/solr/example/example-schemaless/solr/collection1/conf/solrconfig.xml Thu Sep  4 00:16:31 2014
@@ -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.4
         title^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' spellchecker
            and 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>

Modified: lucene/dev/trunk/solr/example/solr/collection1/conf/solrconfig.xml
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/example/solr/collection1/conf/solrconfig.xml?rev=1622384&r1=1622383&r2=1622384&view=diff
==============================================================================
--- lucene/dev/trunk/solr/example/solr/collection1/conf/solrconfig.xml (original)
+++ lucene/dev/trunk/solr/example/solr/collection1/conf/solrconfig.xml Thu Sep  4 00:16:31 2014
@@ -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 specified
          to 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.4
           title^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 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
-      -->
-    <!--
-       <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' spellchecker
            and 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>