SOLR-9005: Add guard condition to the example js

This commit is contained in:
Alexandre Rafalovitch 2016-11-06 15:04:28 +11:00
parent 94c796968a
commit 9148362617
2 changed files with 8 additions and 1 deletions

View File

@ -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
----------------------

View File

@ -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();