lucene-solr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Apache Wiki <wikidi...@apache.org>
Subject [Solr Wiki] Update of "ScriptUpdateProcessor" by ErikHatcher
Date Wed, 09 Jan 2013 10:42:00 GMT
Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Solr Wiki" for change notification.

The "ScriptUpdateProcessor" page has been changed by ErikHatcher:
http://wiki.apache.org/solr/ScriptUpdateProcessor?action=diff&rev1=8&rev2=9

  
  The processAdd() and the other script methods can return false to skip further processing
of the document.  All methods must be defined, though generally the processAdd() method is
where the action is.
  
- == !JavaScript ==
+ == JavaScript ==
  
  Note: There is a !JavaScript example (update-script.js) built into the Solr 4 and up example
collection1 configuration.  Check solrconfig.xml and uncomment the update request processor
definition to enable this feature.
  
@@ -118, +118 @@

  
  == JRuby ==
  
-   TBD
+ To use JRuby as the scripting engine, add jruby.jar to your system (in a lib/ directory
under a collection, or via <lib> directives in solrconfig.xml).
+ 
+ Here's an example JRuby update processing script (note that all variables passed require
prefixing with $, such as $logger):
+ 
+ {{{
+ def processAdd(cmd)
+   doc = cmd.solrDoc  # org.apache.solr.common.SolrInputDocument
+   id = doc.getFieldValue('id')
+ 
+   $logger.info "update-script#processAdd: id=#{id}"
+ 
+   doc.setField('source_s', 'ruby')
+ 
+   $logger.info "update-script#processAdd: config_param=#{$params.get('config_param')}"
+ end
+ 
+ def processDelete(cmd)
+   # no-op
+ end
+ 
+ def processMergeIndexes(cmd)
+   # no-op
+ end
+ 
+ def processCommit(cmd)
+   # no-op
+ end
+ 
+ def processRollback(cmd)
+   # no-op
+ end
+ 
+ def finish()
+   # no-op
+ end
+ }}}
+ 
+ ==== Known issues ====
+ 
+ The following in JRuby do not work as expected for some reason, though it does work properly
in JavaScript:
+ 
+ {{{
+ #  $logger.info "update-script#processAdd: request_param=#{$req.getParams('request_param')}"
+ #  $rsp.add('script_processed',id)       # this is not working!
+ }}}
  
  == Jython ==
  
-   TBD
+   TODO
  
  = Caveats =
  
- TBD: More on the "stateless" nature, running multiple scripts that can share state, and
more about other scripting languages available.
+ TBD: Add more on the "stateless" nature, running multiple scripts that can share state,
and more about other scripting languages available.
  
  = Resources =
  

Mime
View raw message