You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by sa...@apache.org on 2016/11/07 16:50:29 UTC

[15/19] lucene-solr:apiv2: SOLR-9005: Add guard condition to the example js

SOLR-9005: Add guard condition to the example js


Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/91483626
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/91483626
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/91483626

Branch: refs/heads/apiv2
Commit: 9148362617333458e22d7d3c28b26053f4308fa6
Parents: 94c7969
Author: Alexandre Rafalovitch <ar...@apache.org>
Authored: Sun Nov 6 15:04:28 2016 +1100
Committer: Alexandre Rafalovitch <ar...@apache.org>
Committed: Sun Nov 6 15:04:28 2016 +1100

----------------------------------------------------------------------
 solr/CHANGES.txt                         | 2 ++
 solr/example/files/conf/update-script.js | 7 ++++++-
 2 files changed, 8 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/91483626/solr/CHANGES.txt
----------------------------------------------------------------------
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 1109ef7..2e6487d 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -122,6 +122,8 @@ Bug Fixes
 
 * SOLR-9624: In Admin UI, do not attempt to highlight CSV output (Alexandre Rafalovitch)
 
+* SOLR-9005: In files example, add a guard condition to javascript URP script (Alexandre Rafalovitch)
+
 Other Changes
 ----------------------
 

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/91483626/solr/example/files/conf/update-script.js
----------------------------------------------------------------------
diff --git a/solr/example/files/conf/update-script.js b/solr/example/files/conf/update-script.js
index 0991c88..10a955d 100644
--- a/solr/example/files/conf/update-script.js
+++ b/solr/example/files/conf/update-script.js
@@ -72,13 +72,18 @@ function processAdd(cmd) {
     doc.setField("content_type_subtype_s", ct_subtype);
   }
 
+  var content = doc.getFieldValue("content");
+  if (!content) {
+	  return; //No content found, so we are done here
+  }
+
     var analyzer =
          req.getCore().getLatestSchema()
          .getFieldTypeByName("text_email_url")
          .getIndexAnalyzer();
 
   var token_stream =
-       analyzer.tokenStream("content", doc.getFieldValue("content"));
+       analyzer.tokenStream("content", 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();