diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt index 2d3c27935ad..a922a80b0f8 100644 --- a/lucene/CHANGES.txt +++ b/lucene/CHANGES.txt @@ -186,6 +186,8 @@ Bug fixes Other +* LUCENE-9631: Properly override slice() on subclasses of OffsetRange. (Dawid Weiss) + * LUCENE-9312: Allow gradle builds against arbitrary JVMs. (Tomoko Uchida, Dawid Weiss) * LUCENE-9391: Upgrade HPPC to 0.8.2. (Haoyu Zhai) diff --git a/lucene/highlighter/src/java/org/apache/lucene/search/matchhighlight/MatchHighlighter.java b/lucene/highlighter/src/java/org/apache/lucene/search/matchhighlight/MatchHighlighter.java index d59af2aff61..277a3243e92 100644 --- a/lucene/highlighter/src/java/org/apache/lucene/search/matchhighlight/MatchHighlighter.java +++ b/lucene/highlighter/src/java/org/apache/lucene/search/matchhighlight/MatchHighlighter.java @@ -163,6 +163,11 @@ public class MatchHighlighter { super(from, to); this.query = query; } + + @Override + public QueryOffsetRange slice(int from, int to) { + return new QueryOffsetRange(query, from, to); + } } private static class DocHit { diff --git a/lucene/highlighter/src/java/org/apache/lucene/search/matchhighlight/Passage.java b/lucene/highlighter/src/java/org/apache/lucene/search/matchhighlight/Passage.java index 9a4dc4b0a40..7fafeddfb16 100644 --- a/lucene/highlighter/src/java/org/apache/lucene/search/matchhighlight/Passage.java +++ b/lucene/highlighter/src/java/org/apache/lucene/search/matchhighlight/Passage.java @@ -32,6 +32,15 @@ public class Passage extends OffsetRange { this.markers = markers; } + /** + * Passages can't be sliced as it could split previously determined + * highlight markers. + */ + @Override + public OffsetRange slice(int from, int to) { + throw new RuntimeException("Passages.slice() does not make sense?"); + } + @Override public String toString() { return "[" + super.toString() + ", markers=" + markers + "]";