FAQ
Author: ehatcher
Date: Wed Sep 9 00:18:06 2015
New Revision: 1701884

URL: http://svn.apache.org/r1701884
Log:
SOLR-7978: Fixed example/files update-script.js to be Java 7 and 8 compatible (merged from trunk r1701883)

Added:
     lucene/dev/branches/branch_5x/solr/core/src/test-files/solr/collection1/conf/cross-compatible.js
       - copied unchanged from r1701883, lucene/dev/trunk/solr/core/src/test-files/solr/collection1/conf/cross-compatible.js
Modified:
     lucene/dev/branches/branch_5x/ (props changed)
     lucene/dev/branches/branch_5x/solr/ (props changed)
     lucene/dev/branches/branch_5x/solr/CHANGES.txt (contents, props changed)
     lucene/dev/branches/branch_5x/solr/core/ (props changed)
     lucene/dev/branches/branch_5x/solr/core/src/test-files/solr/collection1/conf/solrconfig-script-updateprocessor.xml
     lucene/dev/branches/branch_5x/solr/core/src/test/org/apache/solr/update/processor/StatelessScriptUpdateProcessorFactoryTest.java
     lucene/dev/branches/branch_5x/solr/example/ (props changed)
     lucene/dev/branches/branch_5x/solr/example/files/conf/update-script.js

Modified: lucene/dev/branches/branch_5x/solr/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/solr/CHANGES.txt?rev=1701884&r1=1701883&r2=1701884&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/solr/CHANGES.txt (original)
+++ lucene/dev/branches/branch_5x/solr/CHANGES.txt Wed Sep 9 00:18:06 2015
@@ -107,6 +107,8 @@ Bug Fixes
  * SOLR-8001: Fixed bugs in field(foo,min) and field(foo,max) when some docs have no values
    (David Smiley, hossman)

+* SOLR-7978: Fixed example/files update-script.js to be Java 7 and 8 compatible. (Erik Hatcher)
+
  Optimizations
  ----------------------


Modified: lucene/dev/branches/branch_5x/solr/core/src/test-files/solr/collection1/conf/solrconfig-script-updateprocessor.xml
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/solr/core/src/test-files/solr/collection1/conf/solrconfig-script-updateprocessor.xml?rev=1701884&r1=1701883&r2=1701884&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/solr/core/src/test-files/solr/collection1/conf/solrconfig-script-updateprocessor.xml (original)
+++ lucene/dev/branches/branch_5x/solr/core/src/test-files/solr/collection1/conf/solrconfig-script-updateprocessor.xml Wed Sep 9 00:18:06 2015
@@ -103,10 +103,17 @@
        <str name="script">throw.error.on.add.updateprocessor.js</str>
      </processor>
    </updateRequestProcessorChain>
+
    <updateRequestProcessorChain name="missing-functions">
      <processor class="solr.StatelessScriptUpdateProcessorFactory">
        <str name="script">missing.functions.updateprocessor.js</str>
      </processor>
    </updateRequestProcessorChain>

+ <updateRequestProcessorChain name="javascript-compatibility">
+ <processor class="solr.StatelessScriptUpdateProcessorFactory">
+ <str name="script">cross-compatible.js</str>
+ </processor>
+ </updateRequestProcessorChain>
+
  </config>

Modified: lucene/dev/branches/branch_5x/solr/core/src/test/org/apache/solr/update/processor/StatelessScriptUpdateProcessorFactoryTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/solr/core/src/test/org/apache/solr/update/processor/StatelessScriptUpdateProcessorFactoryTest.java?rev=1701884&r1=1701883&r2=1701884&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/solr/core/src/test/org/apache/solr/update/processor/StatelessScriptUpdateProcessorFactoryTest.java (original)
+++ lucene/dev/branches/branch_5x/solr/core/src/test/org/apache/solr/update/processor/StatelessScriptUpdateProcessorFactoryTest.java Wed Sep 9 00:18:06 2015
@@ -268,4 +268,14 @@ public class StatelessScriptUpdateProces
      fail("Did not get exception from script");
    }

+ public void testJavaScriptCompatibility() throws Exception {
+ final String chain = "javascript-compatibility";
+ SolrInputDocument d = processAdd(chain,
+ doc(f("id", "5"),
+ f("name", " foo "),
+ f("subject", "BAR")));
+ assertEquals("bar", d.getFieldValue("term_s"));
+
+ }
+
  }

Modified: lucene/dev/branches/branch_5x/solr/example/files/conf/update-script.js
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/solr/example/files/conf/update-script.js?rev=1701884&r1=1701883&r2=1701884&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/solr/example/files/conf/update-script.js (original)
+++ lucene/dev/branches/branch_5x/solr/example/files/conf/update-script.js Wed Sep 9 00:18:06 2015
@@ -1,6 +1,15 @@
-/*
- See http://wiki.apache.org/solr/ScriptUpdateProcessor for more details.
-*/
+function get_class(name) {
+ var clazz;
+ try {
+ // Java8 Nashorn
+ clazz = eval("Java.type(name).class");
+ } catch(e) {
+ // Java7 Rhino
+ clazz = eval("Packages."+name);
+ }
+
+ return clazz;
+}

  function processAdd(cmd) {

@@ -69,10 +78,9 @@ function processAdd(cmd) {
           .getIndexAnalyzer();

    var token_stream =
- analyzer.tokenStream("content", new java.io.StringReader(doc.getFieldValue("content")));
-
- var term_att = token_stream.getAttribute(Packages.org.apache.lucene.analysis.tokenattributes.CharTermAttribute);
- var type_att = token_stream.getAttribute(Packages.org.apache.lucene.analysis.tokenattributes.TypeAttribute);
+ analyzer.tokenStream("content", doc.getFieldValue("content"));
+ var term_att = token_stream.getAttribute(get_class("org.apache.lucene.analysis.tokenattributes.CharTermAttribute"));
+ var type_att = token_stream.getAttribute(get_class("org.apache.lucene.analysis.tokenattributes.TypeAttribute"));
    token_stream.reset();
    while (token_stream.incrementToken()) {
      doc.addField(type_att.type().replaceAll(/\<|\>/g,"").toLowerCase()+"_ss", term_att.toString());

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 1 of 1 | next ›
Discussion Overview
groupcommits @
categorieslucene
postedSep 9, '15 at 12:18a
activeSep 9, '15 at 12:18a
posts1
users1
websitelucene.apache.org

1 user in discussion

Ehatcher: 1 post

People

Translate

site design / logo © 2021 Grokbase