From 11a1b8c1a8fdca9f6314bd61695345737309b630 Mon Sep 17 00:00:00 2001 From: Simon Willnauer Date: Wed, 17 Oct 2018 10:16:31 +0200 Subject: [PATCH] LUCENE-6572: Remove dependency on analyzer-common from highlighing This makes a simplifed copy of LimitTokenOffsetFilter to the highlighting module to detach the dependency on analyzer-common. --- lucene/highlighter/build.xml | 9 +++- .../highlight/LimitTokenOffsetFilter.java | 52 +++++++++++++++++++ .../lucene/search/highlight/TokenSources.java | 1 - 3 files changed, 60 insertions(+), 2 deletions(-) create mode 100644 lucene/highlighter/src/java/org/apache/lucene/search/highlight/LimitTokenOffsetFilter.java diff --git a/lucene/highlighter/build.xml b/lucene/highlighter/build.xml index e0dfa7ef86f..ed6cc74be8a 100644 --- a/lucene/highlighter/build.xml +++ b/lucene/highlighter/build.xml @@ -32,10 +32,17 @@ - + + + + + + + + = zero"); + } + this.maxStartOffset = maxStartOffset; + } + + @Override + public boolean incrementToken() throws IOException { + if (!input.incrementToken()) { + return false; + } + if (offsetAttrib.startOffset() <= maxStartOffset) { + return true; + } + return false; + } +} diff --git a/lucene/highlighter/src/java/org/apache/lucene/search/highlight/TokenSources.java b/lucene/highlighter/src/java/org/apache/lucene/search/highlight/TokenSources.java index 2730f40409a..0c0a63f9400 100644 --- a/lucene/highlighter/src/java/org/apache/lucene/search/highlight/TokenSources.java +++ b/lucene/highlighter/src/java/org/apache/lucene/search/highlight/TokenSources.java @@ -23,7 +23,6 @@ import java.io.IOException; import org.apache.lucene.analysis.Analyzer; import org.apache.lucene.analysis.TokenStream; -import org.apache.lucene.analysis.miscellaneous.LimitTokenOffsetFilter; import org.apache.lucene.document.Document; import org.apache.lucene.index.Fields; import org.apache.lucene.index.IndexReader;