From 9148362617333458e22d7d3c28b26053f4308fa6 Mon Sep 17 00:00:00 2001 From: Alexandre Rafalovitch Date: Sun, 6 Nov 2016 15:04:28 +1100 Subject: [PATCH] SOLR-9005: Add guard condition to the example js --- solr/CHANGES.txt | 2 ++ solr/example/files/conf/update-script.js | 7 ++++++- 2 files changed, 8 insertions(+), 1 deletion(-) 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();