lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Erik Hatcher (JIRA)" <>
Subject [jira] [Commented] (SOLR-1725) Script based UpdateRequestProcessorFactory
Date Sat, 19 May 2012 12:44:10 GMT


Erik Hatcher commented on SOLR-1725:

With the latest patch, you can implement an update processor more simply (not having to implement
every process* and finish() methods) like this:

function processAdd(cmd) {
  doc = cmd.solrDoc;

  doc.addField('foo_s', 'bar');

I think there needs to be a simpler mode such that a script can be assumed to be simply under
processAdd (it's not going to be a common activity to need to implement a processAnythingElse)
where the script is handed a SolrInputDocument cleanly and not (necessarily) having to see
the AddUpdateCommand object at all.

Thoughts on how that should work?   (at the ScriptEngine level, it's cleaner to eval than
it is to invoke a function).  Maybe something like:

    <processor class="solr.ScriptUpdateProcessorFactory">
      <str name="add">add_doc.js</str>

where add_doc.js is evaluated only during processAdd and handed a SolrInputDocument "doc"
(along with the request and logger objects of course).  We can still keep it such that a full
"update processor" can be implemented with script to have the full power of all update processor
> Script based UpdateRequestProcessorFactory
> ------------------------------------------
>                 Key: SOLR-1725
>                 URL:
>             Project: Solr
>          Issue Type: New Feature
>          Components: update
>    Affects Versions: 1.4
>            Reporter: Uri Boness
>            Assignee: Erik Hatcher
>              Labels: UpdateProcessor
>             Fix For: 4.1
>         Attachments: SOLR-1725-rev1.patch, SOLR-1725.patch, SOLR-1725.patch, SOLR-1725.patch,
SOLR-1725.patch, SOLR-1725.patch, SOLR-1725.patch, SOLR-1725.patch, SOLR-1725.patch, SOLR-1725.patch
> A script based UpdateRequestProcessorFactory (Uses JDK6 script engine support). The main
goal of this plugin is to be able to configure/write update processors without the need to
write and package Java code.
> The update request processor factory enables writing update processors in scripts located
in {{solr.solr.home}} directory. The functory accepts one (mandatory) configuration parameter
named {{scripts}} which accepts a comma-separated list of file names. It will look for these
files under the {{conf}} directory in solr home. When multiple scripts are defined, their
execution order is defined by the lexicographical order of the script file name (so {{scriptA.js}}
will be executed before {{scriptB.js}}).
> The script language is resolved based on the script file extension (that is, a *.js files
will be treated as a JavaScript script), therefore an extension is mandatory.
> Each script file is expected to have one or more methods with the same signature as the
methods in the {{UpdateRequestProcessor}} interface. It is *not* required to define all methods,
only those hat are required by the processing logic.
> The following variables are define as global variables for each script:
>  * {{req}} - The SolrQueryRequest
>  * {{rsp}}- The SolrQueryResponse
>  * {{logger}} - A logger that can be used for logging purposes in the script

This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:!default.jspa
For more information on JIRA, see:


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message