SOLR-13965: In GraphHandler, support <expressible> configuration and deprecate <streamFunctions> configuration.

(Eric Pugh via Christine Poerschke)

Closes #1033 pull request.
This commit is contained in:
Eric Pugh 2020-02-26 17:36:33 +00:00 committed by Christine Poerschke
parent 570109f73d
commit a5e372369c
3 changed files with 31 additions and 13 deletions

View File

@ -26,6 +26,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

View File

@ -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();

View File

@ -126,7 +126,7 @@ 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"/>