From 56462b5f9628ba1d465fa005e5106c55494a2011 Mon Sep 17 00:00:00 2001 From: Christine Poerschke Date: Wed, 13 Jul 2022 18:43:31 +0100 Subject: [PATCH] LUCENE-10523: factor out UnifiedHighlighter.newFieldHighlighter() method (#821) --- .../search/uhighlight/UnifiedHighlighter.java | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/lucene/highlighter/src/java/org/apache/lucene/search/uhighlight/UnifiedHighlighter.java b/lucene/highlighter/src/java/org/apache/lucene/search/uhighlight/UnifiedHighlighter.java index 3e872733ce2..f74babab3ae 100644 --- a/lucene/highlighter/src/java/org/apache/lucene/search/uhighlight/UnifiedHighlighter.java +++ b/lucene/highlighter/src/java/org/apache/lucene/search/uhighlight/UnifiedHighlighter.java @@ -1077,7 +1077,7 @@ public class UnifiedHighlighter { String field, Query query, Set allTerms, int maxPassages) { UHComponents components = getHighlightComponents(field, query, allTerms); OffsetSource offsetSource = getOptimizedOffsetSource(components); - return new FieldHighlighter( + return newFieldHighlighter( field, getOffsetStrategy(offsetSource, components), new SplittingBreakIterator(getBreakIterator(field), UnifiedHighlighter.MULTIVAL_SEP_CHAR), @@ -1087,6 +1087,24 @@ public class UnifiedHighlighter { getFormatter(field)); } + protected FieldHighlighter newFieldHighlighter( + String field, + FieldOffsetStrategy fieldOffsetStrategy, + BreakIterator breakIterator, + PassageScorer passageScorer, + int maxPassages, + int maxNoHighlightPassages, + PassageFormatter passageFormatter) { + return new FieldHighlighter( + field, + fieldOffsetStrategy, + breakIterator, + passageScorer, + maxPassages, + maxNoHighlightPassages, + passageFormatter); + } + protected UHComponents getHighlightComponents(String field, Query query, Set allTerms) { Predicate fieldMatcher = getFieldMatcher(field); Set highlightFlags = getFlags(field);