You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by eh...@apache.org on 2015/05/22 16:47:38 UTC

svn commit: r1681133 - in /lucene/dev/branches/branch_5x/solr: ./ core/src/java/org/apache/solr/handler/ core/src/java/org/apache/solr/response/transform/ core/src/java/org/apache/solr/update/processor/ example/ example/files/ webapp/web/js/angular/con...

Author: ehatcher
Date: Fri May 22 14:47:37 2015
New Revision: 1681133

URL: http://svn.apache.org/r1681133
Log:
SOLR-7579: Fix Angular admin UI analysis screen drop-down issue

Added:
    lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/response/transform/HighlightingAugmenter.java   (with props)
    lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/update/processor/FieldsUsedUpdateProcessorFactory.java   (with props)
    lucene/dev/branches/branch_5x/solr/example/files-NOTES.txt   (with props)
Modified:
    lucene/dev/branches/branch_5x/solr/build.xml
    lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/handler/NestedRequestHandler.java
    lucene/dev/branches/branch_5x/solr/example/README.txt
    lucene/dev/branches/branch_5x/solr/example/files/README.txt
    lucene/dev/branches/branch_5x/solr/webapp/web/js/angular/controllers/analysis.js
    lucene/dev/branches/branch_5x/solr/webapp/web/partials/analysis.html

Modified: lucene/dev/branches/branch_5x/solr/build.xml
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/solr/build.xml?rev=1681133&r1=1681132&r2=1681133&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/solr/build.xml (original)
+++ lucene/dev/branches/branch_5x/solr/build.xml Fri May 22 14:47:37 2015
@@ -208,6 +208,11 @@
       <globmapper from="*.mdtext" to="*.html"/>
     </pegdown>
 
+    <pegdown todir="${javadoc.dir}/files">
+      <fileset dir="example/files" includes="README.txt"/>
+      <globmapper from="*.txt" to="*.html"/>
+    </pegdown>
+
     <copy todir="${javadoc.dir}">
       <fileset dir="site/assets" />
     </copy>

Modified: lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/handler/NestedRequestHandler.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/handler/NestedRequestHandler.java?rev=1681133&r1=1681132&r2=1681133&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/handler/NestedRequestHandler.java (original)
+++ lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/handler/NestedRequestHandler.java Fri May 22 14:47:37 2015
@@ -23,7 +23,7 @@ import org.apache.solr.request.SolrReque
 /**An interface for RequestHandlers need to handle all paths under its registered path
  */
 public interface NestedRequestHandler {
-  /** Return a Requestandler to handle a subpath from the path this handler is registered.
+  /** Return a SolrRequestHandler to handle a subpath from the path this handler is registered.
    */
   public SolrRequestHandler getSubHandler(String subPath);
 }

Added: lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/response/transform/HighlightingAugmenter.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/response/transform/HighlightingAugmenter.java?rev=1681133&view=auto
==============================================================================
--- lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/response/transform/HighlightingAugmenter.java (added)
+++ lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/response/transform/HighlightingAugmenter.java Fri May 22 14:47:37 2015
@@ -0,0 +1,37 @@
+package org.apache.solr.response.transform;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.io.IOException;
+
+import org.apache.solr.common.SolrDocument;
+
+/**
+ * Created by erikhatcher on 2/18/15.
+ */
+public class HighlightingAugmenter extends TransformerWithContext {
+  @Override
+  public String getName() {
+    return null;
+  }
+
+  @Override
+  public void transform(SolrDocument doc, int docid) throws IOException {
+
+  }
+}

Added: lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/update/processor/FieldsUsedUpdateProcessorFactory.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/update/processor/FieldsUsedUpdateProcessorFactory.java?rev=1681133&view=auto
==============================================================================
--- lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/update/processor/FieldsUsedUpdateProcessorFactory.java (added)
+++ lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/update/processor/FieldsUsedUpdateProcessorFactory.java Fri May 22 14:47:37 2015
@@ -0,0 +1,105 @@
+package org.apache.solr.update.processor;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collection;
+
+import org.apache.solr.common.SolrException;
+import org.apache.solr.common.SolrInputDocument;
+import org.apache.solr.common.util.NamedList;
+import org.apache.solr.core.SolrCore;
+import org.apache.solr.request.SolrQueryRequest;
+import org.apache.solr.response.SolrQueryResponse;
+import org.apache.solr.update.AddUpdateCommand;
+import org.apache.solr.util.plugin.SolrCoreAware;
+
+public class FieldsUsedUpdateProcessorFactory extends UpdateRequestProcessorFactory
+    implements SolrCoreAware {
+  private FieldMutatingUpdateProcessorFactory.SelectorParams inclusions = new FieldMutatingUpdateProcessorFactory.SelectorParams();
+  private Collection<FieldMutatingUpdateProcessorFactory.SelectorParams> exclusions
+      = new ArrayList<>();
+  private FieldMutatingUpdateProcessor.FieldNameSelector selector = null;
+  private String fieldsUsedFieldName;
+
+  @Override
+  public void init(NamedList args) {
+    inclusions = FieldMutatingUpdateProcessorFactory.parseSelectorParams(args);
+    exclusions = FieldMutatingUpdateProcessorFactory.parseSelectorExclusionParams(args);
+
+    fieldsUsedFieldName = args.get("fieldsUsedFieldName").toString();
+
+    if (0 < args.size()) {
+      throw new SolrException(SolrException.ErrorCode.SERVER_ERROR,
+          "Unexpected init param(s): '" + args.getName(0) + "'");
+    }
+
+    super.init(args);
+  }
+
+  @Override
+  public void inform(SolrCore core) {
+    selector =
+        FieldMutatingUpdateProcessor.createFieldNameSelector
+            (core.getResourceLoader(), core, inclusions, FieldMutatingUpdateProcessor.SELECT_ALL_FIELDS);
+
+    for (FieldMutatingUpdateProcessorFactory.SelectorParams exc : exclusions) {
+      selector = FieldMutatingUpdateProcessor.wrap
+          (selector,
+              FieldMutatingUpdateProcessor.createFieldNameSelector
+                  (core.getResourceLoader(), core, exc, FieldMutatingUpdateProcessor.SELECT_NO_FIELDS));
+    }
+  }
+
+
+  @Override
+  public UpdateRequestProcessor getInstance(SolrQueryRequest req, SolrQueryResponse rsp, UpdateRequestProcessor next) {
+    return new FieldsUsedUpdateProcessor(selector, fieldsUsedFieldName, next);
+  }
+
+  private class FieldsUsedUpdateProcessor extends UpdateRequestProcessor {
+    private final FieldMutatingUpdateProcessor.FieldNameSelector selector;
+    private final String fieldsUsedFieldName;
+
+    public FieldsUsedUpdateProcessor(FieldMutatingUpdateProcessor.FieldNameSelector selector,
+                                     String fieldsUsedFieldName, UpdateRequestProcessor next) {
+      super(next);
+      this.selector = selector;
+      this.fieldsUsedFieldName = fieldsUsedFieldName;
+    }
+
+    @Override
+    public void processAdd(AddUpdateCommand cmd) throws IOException {
+      final SolrInputDocument doc = cmd.getSolrInputDocument();
+
+      Collection<String> fieldsUsed = new ArrayList<String>();
+
+      for (final String fname : doc.getFieldNames()) {
+
+        if (selector.shouldMutate(fname)) {
+          fieldsUsed.add(fname);
+        }
+      }
+
+      doc.addField(fieldsUsedFieldName, fieldsUsed.toArray());
+
+      super.processAdd(cmd);
+    }
+  }
+}

Modified: lucene/dev/branches/branch_5x/solr/example/README.txt
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/solr/example/README.txt?rev=1681133&r1=1681132&r2=1681133&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/solr/example/README.txt (original)
+++ lucene/dev/branches/branch_5x/solr/example/README.txt Fri May 22 14:47:37 2015
@@ -13,6 +13,8 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+TODO: Need to update!
+
 Solr example
 ------------
 

Added: lucene/dev/branches/branch_5x/solr/example/files-NOTES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/solr/example/files-NOTES.txt?rev=1681133&view=auto
==============================================================================
--- lucene/dev/branches/branch_5x/solr/example/files-NOTES.txt (added)
+++ lucene/dev/branches/branch_5x/solr/example/files-NOTES.txt Fri May 22 14:47:37 2015
@@ -0,0 +1,23 @@
+move CSS to separate file out of head.vm (to avoid #-macro conflict with CSS id's)
+
+Do some localization of text resources in resources.properties (otherwise remove resources.properties)
+
+edismax configuration
+
+autocommit settings tuning?
+
+-filetypes "*" - in FAQ
+
+clean up macros.vm - only stuff needed, not copied    // macro cleanup!!!
+
+clean up schema and field types?   no need for all those languages for now, is there?
+
+file JIRA for a "sub-handler" capability for /browse... /browse/images?.... see NestedRequestHandler interface
+
+add suggest - new JIRA
+
+is MLT working?
+
+double-check admin UI link and quality
+
+Add this trick somewhere, at least as a bin/solr comment: -a "-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005"
\ No newline at end of file

Modified: lucene/dev/branches/branch_5x/solr/example/files/README.txt
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/solr/example/files/README.txt?rev=1681133&r1=1681132&r2=1681133&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/solr/example/files/README.txt (original)
+++ lucene/dev/branches/branch_5x/solr/example/files/README.txt Fri May 22 14:47:37 2015
@@ -134,23 +134,20 @@ You can use the Admin_UI as a visual too
 	re-create or patch a core/collection with an updated configuration), Solr can be started with a special system property
 	set to the _absolute_ path to the conf/velocity directory, like this:
 
-
 	 bin/solr start -Dvelocity.template.base.dir=</full/path/to>/example/files/conf/velocity/
+
+* How do I index image files?  Or how do I get all files index?
+
+	The bin/post tool has a built-in default constrained list of file types that it will index.  (see `bin/post -h` for
+	details).  In order to index all file types, add `-filetypes "*"` (note the double quotes to avoid shell filename expansion)
+	or `-filetypes png,tiff,jpg` to index those image types.  Full example:
+
+	   bin/post -c files ~/Documents -filetypes png # to index just PNG files
 	
-	
+## Concise Script
+
 bin/solr stop
 rm -Rf server/solr/files/
-
-# templates extracted with:
-#    unzip  -j dist/solr-velocity-*.jar velocity/* -x *.properties -d example/files/templates/
-bin/solr start -Dvelocity.template.base.dir=<absolute path to example/files/templates>
-# TODO: make it so an install dir relative path can be used somehow?
-bin/solr create_core -c files
+bin/solr start # -Dvelocity.template.base.dir=<absolute path to example/files/templates>
+bin/solr core -c files -d example/files/conf
 bin/post -c files ~/Documents
-curl http://localhost:8983/solr/files/config/params -H 'Content-type:application/json'  -d '{
-"update" : {
-  "facets": {
-    "facet.field":"content_type"
-    }
-  }
-}'
\ No newline at end of file

Modified: lucene/dev/branches/branch_5x/solr/webapp/web/js/angular/controllers/analysis.js
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/solr/webapp/web/js/angular/controllers/analysis.js?rev=1681133&r1=1681132&r2=1681133&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/solr/webapp/web/js/angular/controllers/analysis.js (original)
+++ lucene/dev/branches/branch_5x/solr/webapp/web/js/angular/controllers/analysis.js Fri May 22 14:47:37 2015
@@ -17,20 +17,7 @@
 
 solrAdminApp.controller('AnalysisController',
   function($scope, $location, $routeParams, Luke, Analysis) {
-    $scope.resetMenu("analysis");
-
-    // Read initial values from URL:
-    $scope.init = function() {
-      var params = $location.search();
-      $scope.indexText = params["analysis.fieldvalue"];
-      $scope.queryText = params["analysis.query"];
-      if (params["analysis.fieldname"]) {
-        $scope.fieldOrType = "fieldname=" + params["analysis.fieldname"];
-      } else {
-        $scope.fieldOrType = "fieldtype=" + params["analysis.fieldtype"];
-      }
-      $scope.verbose = params["verboxe_output"]=="1";
-    };
+      $scope.resetMenu("analysis");
 
       $scope.refresh = function() {
         Luke.schema({core: $routeParams.core}, function(data) {
@@ -49,20 +36,9 @@ solrAdminApp.controller('AnalysisControl
           }
         });
 
+        $scope.parseQueryString();
         // @todo - if URL param, set $scope.verbose;
         // @todo - set defaultSearchField either to context["analysis.fieldname"] or context["analysis.fieldtype"]
-        /** @todo: not sure:
-                      var fields = 0;
-              for( var key in context.params )
-              {
-                if( 'string' === typeof context.params[key] && 0 !== context.params[key].length )
-                {
-                  fields++;
-                  $( '[name="' + key + '"]', analysis_form )
-                    .val( context.params[key] );
-                }
-              }
-          */
 
       };
       $scope.verbose = true;
@@ -111,62 +87,85 @@ solrAdminApp.controller('AnalysisControl
         return tokens;
       };
 
-      var mangle = function(data) {
-        response = [];
-        for (var i=0; i < data.length; i+=2) {
-          var component = {
-            name: data[i],
-            short: getShortComponentName(data[i]),
-            captions: getCaptionsForComponent(data[i+1]),
-            tokens: getTokensForComponent(data[i+1])
-          };
-          response.push(component);
+      var extractComponents = function(data, result, name) {
+        if (data) {
+            result[name] = [];
+            for (var i = 0; i < data.length; i += 2) {
+                var component = {
+                    name: data[i],
+                    short: getShortComponentName(data[i]),
+                    captions: getCaptionsForComponent(data[i + 1]),
+                    tokens: getTokensForComponent(data[i + 1])
+                };
+                result[name].push(component);
+            }
         }
-        return response;
       };
 
       var processAnalysisData = function(analysis, fieldOrType) {
         var fieldname;
-        console.log(fieldOrType);
-        console.dir(analysis[fieldOrType]);
         for (fieldname in analysis[fieldOrType]) {console.log(fieldname);break;}
-        var index = mangle(analysis[fieldOrType][fieldname].index);
-        var query = mangle(analysis[fieldOrType][fieldname].query);
-        response = {index: index, query: query};
+        var response = {};
+        extractComponents(analysis[fieldOrType][fieldname].index, response, "index");
+        extractComponents(analysis[fieldOrType][fieldname].query, response, "query");
         return response;
       };
 
-      $scope.analyse = function() {
+      $scope.updateQueryString = function() {
+
         var parts = $scope.fieldOrType.split("=");
-        var fieldOrType = parts[0] == "fieldname" ? "field_names" : "field_types";
+        var fieldOrType = parts[0];
+        var name = parts[1];
 
-        params = {
-          "analysis.fieldvalue": $scope.indexText,
-          "analysis.query": $scope.queryText
-        };
+        if ($scope.indexText) {
+            $location.search("analysis.fieldvalue", $scope.indexText);
+        }
+        if ($scope.queryText) {
+          $location.search("analysis.query", $scope.queryText);
+        }
 
-        if (fieldOrType == "field_names") {
-          params["analysis.fieldname"] = parts[1];
+        if (fieldOrType == "fieldname") {
+          $location.search("analysis.fieldname", name);
+          $location.search("analysis.fieldtype", null);
         } else {
-          params["analysis.fieldtype"] = parts[1];
+          $location.search("analysis.fieldtype", name);
+          $location.search("analysis.fieldname", null);
         }
+      };
 
-        $location.search("analysis.fieldname", null);
-        $location.search("analysis.fieldtype", null);
-        for (var param in params) {
-          $location.search(param, params[param]);
-        }
+      $scope.parseQueryString = function () {
+          var params = {};
+          var search = $location.search();
 
-        params.core = $routeParams.core;
-        Analysis.field(params, function(data) {
-          $scope.analysis = data;
-          $scope.result = processAnalysisData(data.analysis, fieldOrType);
-        });
+          if (Object.keys(search).length == 0) {
+              return;
+          }
+          for (var key in search) {
+              params[key]=search[key];
+          }
+          $scope.indexText = search["analysis.fieldvalue"];
+          $scope.queryText = search["analysis.query"];
+          if (search["analysis.fieldname"]) {
+              $scope.fieldOrType = "fieldname=" + search["analysis.fieldname"];
+          } else {
+              $scope.fieldOrType = "fieldtype=" + search["analysis.fieldtype"];
+          }
+          $scope.verbose = search["verbose_output"] == "1";
+
+          if ($scope.fieldOrType || $scope.indexText || $scope.queryText) {
+            params.core = $routeParams.core;
+            var parts = $scope.fieldOrType.split("=");
+            var fieldOrType = parts[0] == "fieldname" ? "field_names" : "field_types";
+
+              Analysis.field(params, function(data) {
+              $scope.result = processAnalysisData(data.analysis, fieldOrType);
+            });
+          }
       };
 
+
       $scope.toggleVerbose = function() {$scope.verbose = !$scope.verbose};
 
-      $scope.init();
       $scope.refresh();
     }
 );

Modified: lucene/dev/branches/branch_5x/solr/webapp/web/partials/analysis.html
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/solr/webapp/web/partials/analysis.html?rev=1681133&r1=1681132&r2=1681133&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/solr/webapp/web/partials/analysis.html (original)
+++ lucene/dev/branches/branch_5x/solr/webapp/web/partials/analysis.html Fri May 22 14:47:37 2015
@@ -41,13 +41,13 @@ limitations under the License.
           <li class="settings-holder clearfix">
             <div class="settings clearfix">
               <label for="type_or_name">Analyse Fieldname / FieldType:</label>
-              <select chosen id="type_or_name" ng-model="fieldOrType" ng-options="f.value as f.label group by f.group for f in fieldsAndTypes"></select>
+              <select style="width:130px" chosen id="type_or_name" ng-model="fieldOrType" ng-options="f.value as f.label group by f.group for f in fieldsAndTypes"></select>
 
               <a id="tor_schema" href="#"><span>Schema Browser</span>&nbsp;</a>
 
               <div class="buttons clearfix">
 
-                <button type="submit" ng-click="analyse()"><span>Analyse Values</span></button>
+                <button type="submit" ng-click="updateQueryString()"><span>Analyse Values</span></button>
 
                 <div class="verbose_output" ng-class="{active:verbose}">
                   <a ng-click="toggleVerbose()">Verbose Output</a>