Apache Lucene open-source search software
LUCENE-2524: FastVectorHighlighter: use mod for getting colored tag
Koji Sekiguchi350ae952d71c
diff --git a/lucene/contrib/CHANGES.txt b/lucene/contrib/CHANGES.txtindex 91c134a0b8c..88cbf41f5ed 100644--- a/lucene/contrib/CHANGES.txt+++ b/lucene/contrib/CHANGES.txt@@ -86,6 +86,9 @@ Bug fixes* LUCENE-2404: Fix bugs with position increment and empty tokens in ThaiWordFilter.For matchVersion >= 3.1 the filter also no longer lowercases. ThaiAnalyzerwill use a separate LowerCaseFilter instead. (Uwe Schindler, Robert Muir)++* LUCENE-2524: FastVectorHighlighter: use mod for getting colored tag.+ (Koji Sekiguchi)API Changesdiff --git a/lucene/contrib/highlighter/src/java/org/apache/lucene/search/vectorhighlight/BaseFragmentsBuilder.java b/lucene/contrib/highlighter/src/java/org/apache/lucene/search/vectorhighlight/BaseFragmentsBuilder.javaindex 9b22433bbed..df8e8089827 100644--- a/lucene/contrib/highlighter/src/java/org/apache/lucene/search/vectorhighlight/BaseFragmentsBuilder.java+++ b/lucene/contrib/highlighter/src/java/org/apache/lucene/search/vectorhighlight/BaseFragmentsBuilder.java@@ -36,7 +36,10 @@ public abstract class BaseFragmentsBuilder implements FragmentsBuilder {"<b style=\"background:yellow\">", "<b style=\"background:lawngreen\">", "<b style=\"background:aquamarine\">","<b style=\"background:magenta\">", "<b style=\"background:palegreen\">", "<b style=\"background:coral\">","<b style=\"background:wheat\">", "<b style=\"background:khaki\">", "<b style=\"background:lime\">",- "<b style=\"background:deepskyblue\">"+ "<b style=\"background:deepskyblue\">", "<b style=\"background:deeppink\">", "<b style=\"background:salmon\">",+ "<b style=\"background:peachpuff\">", "<b style=\"background:violet\">", "<b style=\"background:mediumpurple\">",+ "<b style=\"background:palegoldenrod\">", "<b style=\"background:darkkhaki\">", "<b style=\"background:springgreen\">",+ "<b style=\"background:turquoise\">", "<b style=\"background:powderblue\">"};public static final String[] COLORED_POST_TAGS = { "</b>" };@@ -145,10 +148,12 @@ public abstract class BaseFragmentsBuilder implements FragmentsBuilder {}protected String getPreTag( int num ){- return preTags.length > num ? preTags[num] : preTags[0];+ int n = num % preTags.length;+ return preTags[n];}protected String getPostTag( int num ){- return postTags.length > num ? postTags[num] : postTags[0];+ int n = num % postTags.length;+ return postTags[n];}}