You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by eh...@apache.org on 2012/07/28 05:30:51 UTC
svn commit: r1366588 - in /lucene/dev/trunk/solr: CHANGES.txt
example/solr/collection1/conf/solrconfig.xml
example/solr/collection1/conf/update-script.js
Author: ehatcher
Date: Sat Jul 28 03:30:51 2012
New Revision: 1366588
URL: http://svn.apache.org/viewvc?rev=1366588&view=rev
Log:
SOLR-1280,SOLR-1725: Add an example of the script update processor
Added:
lucene/dev/trunk/solr/example/solr/collection1/conf/update-script.js
Modified:
lucene/dev/trunk/solr/CHANGES.txt
lucene/dev/trunk/solr/example/solr/collection1/conf/solrconfig.xml
Modified: lucene/dev/trunk/solr/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/CHANGES.txt?rev=1366588&r1=1366587&r2=1366588&view=diff
==============================================================================
--- lucene/dev/trunk/solr/CHANGES.txt (original)
+++ lucene/dev/trunk/solr/CHANGES.txt Sat Jul 28 03:30:51 2012
@@ -93,6 +93,9 @@ New Features
be accessible from the STATUS command until they are "reset" by
creating/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
----------------------
Modified: lucene/dev/trunk/solr/example/solr/collection1/conf/solrconfig.xml
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/example/solr/collection1/conf/solrconfig.xml?rev=1366588&r1=1366587&r2=1366588&view=diff
==============================================================================
--- lucene/dev/trunk/solr/example/solr/collection1/conf/solrconfig.xml (original)
+++ lucene/dev/trunk/solr/example/solr/collection1/conf/solrconfig.xml Sat Jul 28 03:30:51 2012
@@ -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 Writers
Added: lucene/dev/trunk/solr/example/solr/collection1/conf/update-script.js
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/example/solr/collection1/conf/update-script.js?rev=1366588&view=auto
==============================================================================
--- lucene/dev/trunk/solr/example/solr/collection1/conf/update-script.js (added)
+++ lucene/dev/trunk/solr/example/solr/collection1/conf/update-script.js Sat Jul 28 03:30:51 2012
@@ -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
+}