You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by cp...@apache.org on 2020/02/26 17:58:30 UTC

[lucene-solr] 01/02: SOLR-13965: In GraphHandler, support configuration and deprecate configuration.

This is an automated email from the ASF dual-hosted git repository.

cpoerschke pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git

commit b4f3efbf94e20cf0687c5a8f7b255eb48c1d8e78
Author: Eric Pugh <ep...@opensourceconnections.com>
AuthorDate: Wed Feb 26 17:36:33 2020 +0000

    SOLR-13965: In GraphHandler, support <expressible> configuration and deprecate <streamFunctions> configuration.
    
    (Eric Pugh via Christine Poerschke)
    
    Closes #1033 pull request.
---
 solr/CHANGES.txt                                   |  3 ++
 .../java/org/apache/solr/handler/GraphHandler.java | 37 +++++++++++++++-------
 solr/solr-ref-guide/src/streaming-expressions.adoc |  4 +--
 3 files changed, 31 insertions(+), 13 deletions(-)

diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 26f46b9..26cbf9b 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -62,6 +62,9 @@ New Features
 
  * SOLR-14241: New delete() Stream Decorator (hossman)
 
+ * SOLR-13965: In GraphHandler, support <expressible> configuration and deprecate <streamFunctions> configuration.
+   (Eric Pugh via Christine Poerschke)
+
 Improvements
 ---------------------
 * SOLR-14120: Define JavaScript methods 'includes' and 'startsWith' to ensure AdminUI can be displayed when using
diff --git a/solr/core/src/java/org/apache/solr/handler/GraphHandler.java b/solr/core/src/java/org/apache/solr/handler/GraphHandler.java
index a50855d..bed4086 100644
--- a/solr/core/src/java/org/apache/solr/handler/GraphHandler.java
+++ b/solr/core/src/java/org/apache/solr/handler/GraphHandler.java
@@ -54,6 +54,28 @@ import org.slf4j.LoggerFactory;
 
 
 /**
+ * <p>
+ * Solr Request Handler for graph traversal with streaming functions that responds with GraphML markup.
+ * </p>
+ * <p>
+ * It loads the default set of streaming expression functions via {@link org.apache.solr.client.solrj.io.stream.expr.DefaultStreamFactory}.
+ * </p>
+ * <p>
+ * To add additional functions, just define them as plugins in solrconfig.xml via
+ * {@code
+ * &lt;expressible name="count" class="org.apache.solr.client.solrj.io.stream.RecordCountStream" /&gt;
+ * }
+ * </p>
+ * <p>
+ * The @deprecated configuration method as of Solr 8.5 is
+  * {@code
+ *  &lt;lst name="streamFunctions"&gt;
+ *    &lt;str name="group"&gt;org.apache.solr.client.solrj.io.stream.ReducerStream&lt;/str&gt;
+ *    &lt;str name="count"&gt;org.apache.solr.client.solrj.io.stream.RecordCountStream&lt;/str&gt;
+ *  &lt;/lst&gt;
+  * }
+ *</p>
+ *
  * @since 6.1.0
  */
 public class GraphHandler extends RequestHandlerBase implements SolrCoreAware, PermissionNameProvider {
@@ -68,17 +90,6 @@ public class GraphHandler extends RequestHandlerBase implements SolrCoreAware, P
   }
 
   public void inform(SolrCore core) {
-
-    /* The stream factory will always contain the zkUrl for the given collection
-     * Adds default streams with their corresponding function names. These
-     * defaults can be overridden or added to in the solrConfig in the stream
-     * RequestHandler def. Example config override
-     *  <lst name="streamFunctions">
-     *    <str name="group">org.apache.solr.client.solrj.io.stream.ReducerStream</str>
-     *    <str name="count">org.apache.solr.client.solrj.io.stream.RecordCountStream</str>
-     *  </lst>
-     * */
-
     String defaultCollection;
     String defaultZkhost;
     CoreContainer coreContainer = core.getCoreContainer();
@@ -92,8 +103,12 @@ public class GraphHandler extends RequestHandlerBase implements SolrCoreAware, P
     }
 
     // This pulls all the overrides and additions from the config
+    StreamHandler.addExpressiblePlugins(streamFactory, core);
+
+    // Check deprecated approach.
     Object functionMappingsObj = initArgs.get("streamFunctions");
     if(null != functionMappingsObj){
+      log.warn("solrconfig.xml: <streamFunctions> is deprecated for adding additional streaming functions to GraphHandler.");
       NamedList<?> functionMappings = (NamedList<?>)functionMappingsObj;
       for(Entry<String,?> functionMapping : functionMappings) {
         String key = functionMapping.getKey();
diff --git a/solr/solr-ref-guide/src/streaming-expressions.adoc b/solr/solr-ref-guide/src/streaming-expressions.adoc
index 46639cb..a49afca 100644
--- a/solr/solr-ref-guide/src/streaming-expressions.adoc
+++ b/solr/solr-ref-guide/src/streaming-expressions.adoc
@@ -135,10 +135,10 @@ The value of `shards.preference` that is used to route requests is determined in
 === Adding Custom Expressions
 
 Creating your own custom expressions can be easily done by implementing the {solr-javadocs}/solr-solrj/org/apache/solr/client/solrj/io/stream/expr/Expressible.html[Expressible] interface.   To add a custom expression to the
-list of known mappings for the `/stream` handler, you just need to declare it as a plugin in `solrconfig.xml` via:
+list of known mappings for the `/stream` and `/graph` handlers, you just need to declare it as a plugin in `solrconfig.xml` via:
 
 [source,xml]
-<expressible name="custom" class="org.example.CustomStreamingExpression"/> 
+<expressible name="custom" class="org.example.CustomStreamingExpression"/>
 
 
 == Types of Streaming Expressions