Apache Lucene open-source search software
SOLR-1280,SOLR-1725: Add an example of the script update processor
Erik Hatcherd0c4ec62c97c
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txtindex abeefe3829b..928d865de23 100644--- a/solr/CHANGES.txt+++ b/solr/CHANGES.txt@@ -93,6 +93,9 @@ New Featuresbe accessible from the STATUS command until they are "reset" bycreating/renaming a SolrCore with the same name. (hossman)+* SOLR-1280: Added commented-out example of the new script update processor+ to the example configuration. See http://wiki.apache.org/solr/ScriptUpdateProcessor (ehatcher)+Bug Fixes----------------------diff --git a/solr/example/solr/collection1/conf/solrconfig.xml b/solr/example/solr/collection1/conf/solrconfig.xmlindex acfc1dbfa9b..8405d774ff3 100755--- a/solr/example/solr/collection1/conf/solrconfig.xml+++ b/solr/example/solr/collection1/conf/solrconfig.xml@@ -1609,6 +1609,24 @@<processor class="solr.RunUpdateProcessorFactory" /></updateRequestProcessorChain>-->++ <!-- Script update processor++ This example hooks in an update processor implemented using JavaScript.++ See more about the script update processor at http://wiki.apache.org/solr/ScriptUpdateProcessor+ -->+ <!--+ <updateRequestProcessorChain name="script">+ <processor class="solr.StatelessScriptUpdateProcessorFactory">+ <str name="script">update-script.js</str>+ <lst name="params">+ <str name="config_param">example config parameter</str>+ </lst>+ </processor>+ <processor class="solr.RunUpdateProcessorFactory" />+ </updateRequestProcessorChain>+ --><!-- Response Writersdiff --git a/solr/example/solr/collection1/conf/update-script.js b/solr/example/solr/collection1/conf/update-script.jsnew file mode 100644index 00000000000..88db14d3dae--- /dev/null+++ b/solr/example/solr/collection1/conf/update-script.js@@ -0,0 +1,53 @@+/*+ This is a basic skeleton JavaScript update processor.++ In order for this to be executed, it must be properly wired into solrconfig.xml; by default it is commented out in+ the example solrconfig.xml and must be uncommented to be enabled.++ See http://wiki.apache.org/solr/ScriptUpdateProcessor for more details.+*/++function processAdd(cmd) {++ doc = cmd.solrDoc; // org.apache.solr.common.SolrInputDocument+ id =doc.getFieldValue("id");+ logger.info("update-script#processAdd: id=" + id);++// Set a field value:+// doc.setField("foo_s", "whatever");++// Get a configuration parameter:+// config_param = params.get('config_param'); // "params" only exists if processor configured with <lst name="params">++// Get a request parameter:+// some_param = req.getParams().get("some_param")++// Add a field of field names that match a pattern:+// - Potentially useful to determine the fields/attributes represented in a result set, via faceting on field_name_ss+// field_names = doc.getFieldNames().toArray();+// for(i=0; i < field_names.length; i++) {+// field_name = field_names[i];+// if (/attr_.*/.test(field_name)) { doc.addField("field_name_ss", field_names[i]); }+// }++}++function processDelete(cmd) {+ // no-op+}++function processMergeIndexes(cmd) {+ // no-op+}++function processCommit(cmd) {+ // no-op+}++function processRollback(cmd) {+ // no-op+}++function finish() {+ // no-op+}