|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.apache.solr.update.processor.UpdateRequestProcessorFactory
org.apache.solr.update.processor.StatelessScriptUpdateProcessorFactory
public class StatelessScriptUpdateProcessorFactory
An update request processor factory that enables the use of update
processors implemented as scripts which can be loaded by the
SolrResourceLoader (usually via the conf dir for
the SolrCore).
This factory requires at least one configuration parameter named
script which may be the name of a script file as a string,
or an array of multiple script files. If multiple script files are
specified, they are executed sequentially in the order specified in the
configuration -- as if multiple factories were configured sequentially
Each script file is expected to declare functions with the same name
as each method in UpdateRequestProcessor, using the same
arguments. One slight deviation is in the optional return value from
these functions: If a script function has a boolean return
value, and that value is false then the processor will
cleanly terminate processing of the command and return, without forwarding
the command on to the next script or processor in the chain.
Due to limitations in the ScriptEngine API used by
this factory, it can not enforce that all functions exist on initialization,
so errors from missing functions will only be generated at runtime when
the chain attempts to use them.
The factory may also be configured with an optional "params" argument,
which can be an NamedList (or array, or any other simple Java
object) which will be put into the global scope for each script.
The following variables are define as global variables for each script:
SolrQueryRequestSolrQueryResponseLogger that can be used for logging purposes in the script
Internally this update processor uses JDK 6 scripting engine support,
and any Invocable implementations of ScriptEngine
that can be loaded using the Solr Plugin ClassLoader may be used.
By default, the engine used for each script is determined by the filed
extension (ie: a *.js file will be treated as a JavaScript script) but
this can be overridden by specifying an explicit "engine" name init
param for the factory, which identifies a registered name of a
ScriptEngineFactory.
(This may be particularly useful if multiple engines are available for
the same scripting language, and you wish to force the usage of a
particular engine because of known quirks)
A new ScriptEngineManager is created for each
SolrQueryRequest defining a "global" scope for the script(s)
which is request specific. Separate ScriptEngine instances
are then used to evaluate the script files, resulting in an "engine" scope
that is specific to each script.
A simple example...
<processor class="solr.StatelessScriptUpdateProcessorFactory"> <str name="script">updateProcessor.js</str> </processor>
A more complex example involving multiple scripts in different languages,
and a "params" NamedList that will be put into the global
scope of each script...
<processor class="solr.StatelessScriptUpdateProcessorFactory">
<arr name="script">
<str name="script">first-processor.js</str>
<str name="script">second-processor.py</str>
</arr>
<lst name="params">
<bool name="a_bool_value">true</bool>
<int name="and_int_value">3</int>
</lst>
</processor>
An example where the script file extensions are ignored, and an explicit script engine is used....
<processor class="solr.StatelessScriptUpdateProcessorFactory">
<arr name="script">
<str name="script">first-processor.txt</str>
<str name="script">second-processor.txt</str>
</arr>
<str name="engine">rhino</str>
</processor>
| Field Summary | |
|---|---|
static org.slf4j.Logger |
log
|
| Constructor Summary | |
|---|---|
StatelessScriptUpdateProcessorFactory()
|
|
| Method Summary | |
|---|---|
UpdateRequestProcessor |
getInstance(SolrQueryRequest req,
SolrQueryResponse rsp,
UpdateRequestProcessor next)
|
void |
inform(SolrCore core)
|
void |
init(NamedList args)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static org.slf4j.Logger log
| Constructor Detail |
|---|
public StatelessScriptUpdateProcessorFactory()
| Method Detail |
|---|
public void init(NamedList args)
init in interface NamedListInitializedPlugininit in class UpdateRequestProcessorFactory
public UpdateRequestProcessor getInstance(SolrQueryRequest req,
SolrQueryResponse rsp,
UpdateRequestProcessor next)
getInstance in class UpdateRequestProcessorFactorypublic void inform(SolrCore core)
inform in interface SolrCoreAware
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||