Skip to content

Apache Lucene open-source search software

SOLR-9005: Add guard condition to the example js

Alexandre Rafalovitch914836261733
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 1109ef781b4..2e6487dc77c 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
----------------------
diff --git a/solr/example/files/conf/update-script.js b/solr/example/files/conf/update-script.js
index 0991c889413..10a955d9149 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();