From b570fb035212f3399fc7c626d44751dfe8dcb641 Mon Sep 17 00:00:00 2001 From: Alan Woodward Date: Wed, 16 Sep 2015 12:43:31 +0000 Subject: [PATCH] LUCENE-6489: Move Payload queries to queries module and PayloadSpanUtil to sandbox git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1703392 13f79535-47bb-0310-9956-ffa450edef68 --- lucene/CHANGES.txt | 3 + .../tokenattributes/PayloadAttribute.java | 4 +- .../apache/lucene/search/package-info.java | 2 +- .../lucene/search/TestPositionIncrement.java | 39 ++--- .../search/highlight/HighlighterTest.java | 2 +- .../payloads/AveragePayloadFunction.java | 2 +- .../queries}/payloads/MaxPayloadFunction.java | 2 +- .../queries}/payloads/MinPayloadFunction.java | 2 +- .../queries}/payloads/PayloadFunction.java | 4 +- .../queries}/payloads/PayloadScoreQuery.java | 2 +- .../payloads/SpanPayloadCheckQuery.java | 2 +- .../queries}/payloads/package-info.java | 4 +- .../queries}/payloads/PayloadHelper.java | 2 +- .../payloads/TestPayloadCheckQuery.java | 2 +- .../payloads/TestPayloadExplanations.java | 2 +- .../payloads/TestPayloadScoreQuery.java | 2 +- .../queries}/payloads/TestPayloadSpans.java | 141 +++++++----------- .../payloads/TestPayloadTermQuery.java | 2 +- .../xml/builders/BoostingTermBuilder.java | 4 +- .../payloads/PayloadSpanCollector.java | 2 +- .../lucene}/payloads/PayloadSpanUtil.java | 14 +- .../apache/lucene/payloads/package-info.java | 21 +++ .../lucene/payloads/TestPayloadSpanUtil.java | 130 ++++++++++++++++ .../search/spans/MultiSpansWrapper.java | 4 +- .../solr/highlight/HighlighterTest.java | 2 +- 25 files changed, 263 insertions(+), 133 deletions(-) rename lucene/{core/src/java/org/apache/lucene/search => queries/src/java/org/apache/lucene/queries}/payloads/AveragePayloadFunction.java (97%) rename lucene/{core/src/java/org/apache/lucene/search => queries/src/java/org/apache/lucene/queries}/payloads/MaxPayloadFunction.java (97%) rename lucene/{core/src/java/org/apache/lucene/search => queries/src/java/org/apache/lucene/queries}/payloads/MinPayloadFunction.java (97%) rename lucene/{core/src/java/org/apache/lucene/search => queries/src/java/org/apache/lucene/queries}/payloads/PayloadFunction.java (95%) rename lucene/{core/src/java/org/apache/lucene/search => queries/src/java/org/apache/lucene/queries}/payloads/PayloadScoreQuery.java (99%) rename lucene/{core/src/java/org/apache/lucene/search => queries/src/java/org/apache/lucene/queries}/payloads/SpanPayloadCheckQuery.java (99%) rename lucene/{core/src/java/org/apache/lucene/search => queries/src/java/org/apache/lucene/queries}/payloads/package-info.java (87%) rename lucene/{core/src/test/org/apache/lucene/search => queries/src/test/org/apache/lucene/queries}/payloads/PayloadHelper.java (99%) rename lucene/{core/src/test/org/apache/lucene/search => queries/src/test/org/apache/lucene/queries}/payloads/TestPayloadCheckQuery.java (99%) rename lucene/{core/src/test/org/apache/lucene/search => queries/src/test/org/apache/lucene/queries}/payloads/TestPayloadExplanations.java (98%) rename lucene/{core/src/test/org/apache/lucene/search => queries/src/test/org/apache/lucene/queries}/payloads/TestPayloadScoreQuery.java (99%) rename lucene/{core/src/test/org/apache/lucene/search => queries/src/test/org/apache/lucene/queries}/payloads/TestPayloadSpans.java (82%) rename lucene/{core/src/test/org/apache/lucene/search => queries/src/test/org/apache/lucene/queries}/payloads/TestPayloadTermQuery.java (99%) rename lucene/{core/src/java/org/apache/lucene/search => sandbox/src/java/org/apache/lucene}/payloads/PayloadSpanCollector.java (97%) rename lucene/{core/src/java/org/apache/lucene/search => sandbox/src/java/org/apache/lucene}/payloads/PayloadSpanUtil.java (99%) create mode 100644 lucene/sandbox/src/java/org/apache/lucene/payloads/package-info.java create mode 100644 lucene/sandbox/src/test/org/apache/lucene/payloads/TestPayloadSpanUtil.java rename lucene/{core/src/test => test-framework/src/java}/org/apache/lucene/search/spans/MultiSpansWrapper.java (100%) diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt index 43151993a00..1d7f524411a 100644 --- a/lucene/CHANGES.txt +++ b/lucene/CHANGES.txt @@ -90,6 +90,9 @@ API Changes * LUCENE-6716: SpanPayloadCheckQuery now takes a List rather than a Collection. (Alan Woodward) +* LUCENE-6489: The various span payload queries have been moved to the queries + submodule, and PayloadSpanUtil is now in sandbox. (Alan Woodward) + Optimizations * LUCENE-6708: TopFieldCollector does not compute the score several times on the diff --git a/lucene/core/src/java/org/apache/lucene/analysis/tokenattributes/PayloadAttribute.java b/lucene/core/src/java/org/apache/lucene/analysis/tokenattributes/PayloadAttribute.java index f4d09a613bb..fa63d9c361d 100644 --- a/lucene/core/src/java/org/apache/lucene/analysis/tokenattributes/PayloadAttribute.java +++ b/lucene/core/src/java/org/apache/lucene/analysis/tokenattributes/PayloadAttribute.java @@ -24,9 +24,7 @@ import org.apache.lucene.util.BytesRef; * The payload of a Token. *

* The payload is stored in the index at each position, and can - * be used to influence scoring when using Payload-based queries - * in the {@link org.apache.lucene.search.payloads} and - * {@link org.apache.lucene.search.spans} packages. + * be used to influence scoring when using Payload-based queries. *

* NOTE: because the payload will be stored at each position, it's usually * best to use the minimum number of bytes necessary. Some codec implementations diff --git a/lucene/core/src/java/org/apache/lucene/search/package-info.java b/lucene/core/src/java/org/apache/lucene/search/package-info.java index 4fb2b5bc19f..899eb316f32 100644 --- a/lucene/core/src/java/org/apache/lucene/search/package-info.java +++ b/lucene/core/src/java/org/apache/lucene/search/package-info.java @@ -33,7 +33,7 @@ *

Search Basics

*

* Lucene offers a wide variety of {@link org.apache.lucene.search.Query} implementations, most of which are in - * this package, its subpackages ({@link org.apache.lucene.search.spans spans}, {@link org.apache.lucene.search.payloads payloads}), + * this package, its subpackage ({@link org.apache.lucene.search.spans spans}, * or the queries module. These implementations can be combined in a wide * variety of ways to provide complex querying capabilities along with information about where matches took place in the document * collection. The Query Classes section below highlights some of the more important Query classes. For details diff --git a/lucene/core/src/test/org/apache/lucene/search/TestPositionIncrement.java b/lucene/core/src/test/org/apache/lucene/search/TestPositionIncrement.java index 8d05769605f..85e4ebcaa4d 100644 --- a/lucene/core/src/test/org/apache/lucene/search/TestPositionIncrement.java +++ b/lucene/core/src/test/org/apache/lucene/search/TestPositionIncrement.java @@ -19,8 +19,8 @@ package org.apache.lucene.search; import java.io.IOException; import java.io.StringReader; -import java.nio.charset.StandardCharsets; -import java.util.Collection; +import java.util.ArrayList; +import java.util.List; import org.apache.lucene.analysis.Analyzer; import org.apache.lucene.analysis.MockPayloadAnalyzer; @@ -38,9 +38,8 @@ import org.apache.lucene.index.PostingsEnum; import org.apache.lucene.index.RandomIndexWriter; import org.apache.lucene.index.SlowCompositeReaderWrapper; import org.apache.lucene.index.Term; -import org.apache.lucene.search.payloads.PayloadSpanCollector; -import org.apache.lucene.search.payloads.PayloadSpanUtil; import org.apache.lucene.search.spans.MultiSpansWrapper; +import org.apache.lucene.search.spans.SpanCollector; import org.apache.lucene.search.spans.SpanNearQuery; import org.apache.lucene.search.spans.SpanQuery; import org.apache.lucene.search.spans.SpanTermQuery; @@ -201,6 +200,22 @@ public class TestPositionIncrement extends LuceneTestCase { store.close(); } + static class PayloadSpanCollector implements SpanCollector { + + List payloads = new ArrayList<>(); + + @Override + public void collectLeaf(PostingsEnum postings, int position, Term term) throws IOException { + if (postings.getPayload() != null) + payloads.add(BytesRef.deepCopyOf(postings.getPayload())); + } + + @Override + public void reset() { + payloads.clear(); + } + } + public void testPayloadsPos0() throws Exception { Directory dir = newDirectory(); RandomIndexWriter writer = new RandomIndexWriter(random(), dir, new MockPayloadAnalyzer()); @@ -248,12 +263,11 @@ public class TestPositionIncrement extends LuceneTestCase { } collector.reset(); pspans.collect(collector); - Collection payloads = collector.getPayloads(); sawZero |= pspans.startPosition() == 0; - for (byte[] bytes : payloads) { + for (BytesRef payload : collector.payloads) { count++; if (VERBOSE) { - System.out.println(" payload: " + new String(bytes, StandardCharsets.UTF_8)); + System.out.println(" payload: " + Term.toString(payload)); } } } @@ -276,17 +290,6 @@ public class TestPositionIncrement extends LuceneTestCase { assertEquals(4, count); assertTrue(sawZero); - sawZero = false; - PayloadSpanUtil psu = new PayloadSpanUtil(is.getTopReaderContext()); - Collection pls = psu.getPayloadsForQuery(snq); - count = pls.size(); - for (byte[] bytes : pls) { - String s = new String(bytes, StandardCharsets.UTF_8); - //System.out.println(s); - sawZero |= s.equals("pos: 0"); - } - assertEquals(8, count); - assertTrue(sawZero); writer.close(); is.getIndexReader().close(); dir.close(); diff --git a/lucene/highlighter/src/test/org/apache/lucene/search/highlight/HighlighterTest.java b/lucene/highlighter/src/test/org/apache/lucene/search/highlight/HighlighterTest.java index 22d7d835a0d..3689a81b3d3 100644 --- a/lucene/highlighter/src/test/org/apache/lucene/search/highlight/HighlighterTest.java +++ b/lucene/highlighter/src/test/org/apache/lucene/search/highlight/HighlighterTest.java @@ -83,7 +83,7 @@ import org.apache.lucene.search.join.QueryBitSetProducer; import org.apache.lucene.search.join.ScoreMode; import org.apache.lucene.search.join.ToChildBlockJoinQuery; import org.apache.lucene.search.join.ToParentBlockJoinQuery; -import org.apache.lucene.search.payloads.SpanPayloadCheckQuery; +import org.apache.lucene.queries.payloads.SpanPayloadCheckQuery; import org.apache.lucene.search.spans.SpanMultiTermQueryWrapper; import org.apache.lucene.search.spans.SpanNearQuery; import org.apache.lucene.search.spans.SpanNotQuery; diff --git a/lucene/core/src/java/org/apache/lucene/search/payloads/AveragePayloadFunction.java b/lucene/queries/src/java/org/apache/lucene/queries/payloads/AveragePayloadFunction.java similarity index 97% rename from lucene/core/src/java/org/apache/lucene/search/payloads/AveragePayloadFunction.java rename to lucene/queries/src/java/org/apache/lucene/queries/payloads/AveragePayloadFunction.java index 79cded7c52d..1b3c9d80467 100644 --- a/lucene/core/src/java/org/apache/lucene/search/payloads/AveragePayloadFunction.java +++ b/lucene/queries/src/java/org/apache/lucene/queries/payloads/AveragePayloadFunction.java @@ -1,4 +1,4 @@ -package org.apache.lucene.search.payloads; +package org.apache.lucene.queries.payloads; /* * Licensed to the Apache Software Foundation (ASF) under one or more diff --git a/lucene/core/src/java/org/apache/lucene/search/payloads/MaxPayloadFunction.java b/lucene/queries/src/java/org/apache/lucene/queries/payloads/MaxPayloadFunction.java similarity index 97% rename from lucene/core/src/java/org/apache/lucene/search/payloads/MaxPayloadFunction.java rename to lucene/queries/src/java/org/apache/lucene/queries/payloads/MaxPayloadFunction.java index a13b18abb6a..ea30e6523a6 100644 --- a/lucene/core/src/java/org/apache/lucene/search/payloads/MaxPayloadFunction.java +++ b/lucene/queries/src/java/org/apache/lucene/queries/payloads/MaxPayloadFunction.java @@ -1,4 +1,4 @@ -package org.apache.lucene.search.payloads; +package org.apache.lucene.queries.payloads; /* * Licensed to the Apache Software Foundation (ASF) under one or more diff --git a/lucene/core/src/java/org/apache/lucene/search/payloads/MinPayloadFunction.java b/lucene/queries/src/java/org/apache/lucene/queries/payloads/MinPayloadFunction.java similarity index 97% rename from lucene/core/src/java/org/apache/lucene/search/payloads/MinPayloadFunction.java rename to lucene/queries/src/java/org/apache/lucene/queries/payloads/MinPayloadFunction.java index 6e962e75a97..64ab1d190fc 100644 --- a/lucene/core/src/java/org/apache/lucene/search/payloads/MinPayloadFunction.java +++ b/lucene/queries/src/java/org/apache/lucene/queries/payloads/MinPayloadFunction.java @@ -1,4 +1,4 @@ -package org.apache.lucene.search.payloads; +package org.apache.lucene.queries.payloads; /* * Licensed to the Apache Software Foundation (ASF) under one or more diff --git a/lucene/core/src/java/org/apache/lucene/search/payloads/PayloadFunction.java b/lucene/queries/src/java/org/apache/lucene/queries/payloads/PayloadFunction.java similarity index 95% rename from lucene/core/src/java/org/apache/lucene/search/payloads/PayloadFunction.java rename to lucene/queries/src/java/org/apache/lucene/queries/payloads/PayloadFunction.java index e7569b2633f..2a561224c44 100644 --- a/lucene/core/src/java/org/apache/lucene/search/payloads/PayloadFunction.java +++ b/lucene/queries/src/java/org/apache/lucene/queries/payloads/PayloadFunction.java @@ -1,4 +1,4 @@ -package org.apache.lucene.search.payloads; +package org.apache.lucene.queries.payloads; /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with @@ -22,7 +22,7 @@ import org.apache.lucene.search.Explanation; * An abstract class that defines a way for PayloadScoreQuery instances to transform * the cumulative effects of payload scores for a document. * - * @see org.apache.lucene.search.payloads.PayloadScoreQuery for more information + * @see org.apache.lucene.queries.payloads.PayloadScoreQuery for more information * * @lucene.experimental This class and its derivations are experimental and subject to * change diff --git a/lucene/core/src/java/org/apache/lucene/search/payloads/PayloadScoreQuery.java b/lucene/queries/src/java/org/apache/lucene/queries/payloads/PayloadScoreQuery.java similarity index 99% rename from lucene/core/src/java/org/apache/lucene/search/payloads/PayloadScoreQuery.java rename to lucene/queries/src/java/org/apache/lucene/queries/payloads/PayloadScoreQuery.java index 7f54b8c1059..3ba35030cc6 100644 --- a/lucene/core/src/java/org/apache/lucene/search/payloads/PayloadScoreQuery.java +++ b/lucene/queries/src/java/org/apache/lucene/queries/payloads/PayloadScoreQuery.java @@ -1,4 +1,4 @@ -package org.apache.lucene.search.payloads; +package org.apache.lucene.queries.payloads; /* * Licensed to the Apache Software Foundation (ASF) under one or more diff --git a/lucene/core/src/java/org/apache/lucene/search/payloads/SpanPayloadCheckQuery.java b/lucene/queries/src/java/org/apache/lucene/queries/payloads/SpanPayloadCheckQuery.java similarity index 99% rename from lucene/core/src/java/org/apache/lucene/search/payloads/SpanPayloadCheckQuery.java rename to lucene/queries/src/java/org/apache/lucene/queries/payloads/SpanPayloadCheckQuery.java index 446f55c9d06..f0f43f650ee 100644 --- a/lucene/core/src/java/org/apache/lucene/search/payloads/SpanPayloadCheckQuery.java +++ b/lucene/queries/src/java/org/apache/lucene/queries/payloads/SpanPayloadCheckQuery.java @@ -1,4 +1,4 @@ -package org.apache.lucene.search.payloads; +package org.apache.lucene.queries.payloads; /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with diff --git a/lucene/core/src/java/org/apache/lucene/search/payloads/package-info.java b/lucene/queries/src/java/org/apache/lucene/queries/payloads/package-info.java similarity index 87% rename from lucene/core/src/java/org/apache/lucene/search/payloads/package-info.java rename to lucene/queries/src/java/org/apache/lucene/queries/payloads/package-info.java index cd04bf378b8..1eb61e582ee 100644 --- a/lucene/core/src/java/org/apache/lucene/search/payloads/package-info.java +++ b/lucene/queries/src/java/org/apache/lucene/queries/payloads/package-info.java @@ -20,8 +20,8 @@ *

* The following Query implementations are provided: *

    - *
  1. {@link org.apache.lucene.search.payloads.PayloadScoreQuery PayloadScoreQuery} -- For all terms matched by + *
  2. {@link org.apache.lucene.queries.payloads.PayloadScoreQuery PayloadScoreQuery} -- For all terms matched by * a SpanQuery, boost the score based on the value of the payload located at those terms.
  3. *
*/ -package org.apache.lucene.search.payloads; +package org.apache.lucene.queries.payloads; diff --git a/lucene/core/src/test/org/apache/lucene/search/payloads/PayloadHelper.java b/lucene/queries/src/test/org/apache/lucene/queries/payloads/PayloadHelper.java similarity index 99% rename from lucene/core/src/test/org/apache/lucene/search/payloads/PayloadHelper.java rename to lucene/queries/src/test/org/apache/lucene/queries/payloads/PayloadHelper.java index 144b727b8ee..fd65756b02c 100644 --- a/lucene/core/src/test/org/apache/lucene/search/payloads/PayloadHelper.java +++ b/lucene/queries/src/test/org/apache/lucene/queries/payloads/PayloadHelper.java @@ -1,4 +1,4 @@ -package org.apache.lucene.search.payloads; +package org.apache.lucene.queries.payloads; /* * Licensed to the Apache Software Foundation (ASF) under one or more diff --git a/lucene/core/src/test/org/apache/lucene/search/payloads/TestPayloadCheckQuery.java b/lucene/queries/src/test/org/apache/lucene/queries/payloads/TestPayloadCheckQuery.java similarity index 99% rename from lucene/core/src/test/org/apache/lucene/search/payloads/TestPayloadCheckQuery.java rename to lucene/queries/src/test/org/apache/lucene/queries/payloads/TestPayloadCheckQuery.java index 27de482ada1..21ca7fe16f8 100644 --- a/lucene/core/src/test/org/apache/lucene/search/payloads/TestPayloadCheckQuery.java +++ b/lucene/queries/src/test/org/apache/lucene/queries/payloads/TestPayloadCheckQuery.java @@ -1,4 +1,4 @@ -package org.apache.lucene.search.payloads; +package org.apache.lucene.queries.payloads; /* * Licensed to the Apache Software Foundation (ASF) under one or more diff --git a/lucene/core/src/test/org/apache/lucene/search/payloads/TestPayloadExplanations.java b/lucene/queries/src/test/org/apache/lucene/queries/payloads/TestPayloadExplanations.java similarity index 98% rename from lucene/core/src/test/org/apache/lucene/search/payloads/TestPayloadExplanations.java rename to lucene/queries/src/test/org/apache/lucene/queries/payloads/TestPayloadExplanations.java index c08e560e74c..213c1428856 100644 --- a/lucene/core/src/test/org/apache/lucene/search/payloads/TestPayloadExplanations.java +++ b/lucene/queries/src/test/org/apache/lucene/queries/payloads/TestPayloadExplanations.java @@ -1,4 +1,4 @@ -package org.apache.lucene.search.payloads; +package org.apache.lucene.queries.payloads; /* * Licensed to the Apache Software Foundation (ASF) under one or more diff --git a/lucene/core/src/test/org/apache/lucene/search/payloads/TestPayloadScoreQuery.java b/lucene/queries/src/test/org/apache/lucene/queries/payloads/TestPayloadScoreQuery.java similarity index 99% rename from lucene/core/src/test/org/apache/lucene/search/payloads/TestPayloadScoreQuery.java rename to lucene/queries/src/test/org/apache/lucene/queries/payloads/TestPayloadScoreQuery.java index 22242fd3617..c52b3b542d0 100644 --- a/lucene/core/src/test/org/apache/lucene/search/payloads/TestPayloadScoreQuery.java +++ b/lucene/queries/src/test/org/apache/lucene/queries/payloads/TestPayloadScoreQuery.java @@ -1,4 +1,4 @@ -package org.apache.lucene.search.payloads; +package org.apache.lucene.queries.payloads; /* * Licensed to the Apache Software Foundation (ASF) under one or more diff --git a/lucene/core/src/test/org/apache/lucene/search/payloads/TestPayloadSpans.java b/lucene/queries/src/test/org/apache/lucene/queries/payloads/TestPayloadSpans.java similarity index 82% rename from lucene/core/src/test/org/apache/lucene/search/payloads/TestPayloadSpans.java rename to lucene/queries/src/test/org/apache/lucene/queries/payloads/TestPayloadSpans.java index e817ad4e915..ec39d540c95 100644 --- a/lucene/core/src/test/org/apache/lucene/search/payloads/TestPayloadSpans.java +++ b/lucene/queries/src/test/org/apache/lucene/queries/payloads/TestPayloadSpans.java @@ -1,4 +1,4 @@ -package org.apache.lucene.search.payloads; +package org.apache.lucene.queries.payloads; /* * Copyright 2004 The Apache Software Foundation @@ -16,6 +16,13 @@ package org.apache.lucene.search.payloads; * limitations under the License. */ +import java.io.IOException; +import java.io.StringReader; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + import org.apache.lucene.analysis.Analyzer; import org.apache.lucene.analysis.MockTokenizer; import org.apache.lucene.analysis.TokenFilter; @@ -32,11 +39,11 @@ import org.apache.lucene.index.PostingsEnum; import org.apache.lucene.index.RandomIndexWriter; import org.apache.lucene.index.Term; import org.apache.lucene.search.IndexSearcher; -import org.apache.lucene.search.TermQuery; import org.apache.lucene.search.TopDocs; import org.apache.lucene.search.similarities.ClassicSimilarity; import org.apache.lucene.search.similarities.Similarity; import org.apache.lucene.search.spans.MultiSpansWrapper; +import org.apache.lucene.search.spans.SpanCollector; import org.apache.lucene.search.spans.SpanFirstQuery; import org.apache.lucene.search.spans.SpanNearQuery; import org.apache.lucene.search.spans.SpanNotQuery; @@ -48,13 +55,6 @@ import org.apache.lucene.store.Directory; import org.apache.lucene.util.BytesRef; import org.apache.lucene.util.LuceneTestCase; -import java.io.IOException; -import java.io.StringReader; -import java.nio.charset.StandardCharsets; -import java.util.Collection; -import java.util.HashSet; -import java.util.Set; - public class TestPayloadSpans extends LuceneTestCase { private IndexSearcher searcher; private Similarity similarity = new ClassicSimilarity(); @@ -74,15 +74,15 @@ public class TestPayloadSpans extends LuceneTestCase { SpanTermQuery stq; Spans spans; stq = new SpanTermQuery(new Term(PayloadHelper.FIELD, "seventy")); - PayloadSpanCollector collector = new PayloadSpanCollector(); + spans = MultiSpansWrapper.wrap(indexReader, stq, SpanWeight.Postings.PAYLOADS); assertTrue("spans is null and it shouldn't be", spans != null); - checkSpans(spans, collector, 100, 1, 1, 1); + checkSpans(spans, 100, 1, 1, 1); stq = new SpanTermQuery(new Term(PayloadHelper.NO_PAYLOAD_FIELD, "seventy")); spans = MultiSpansWrapper.wrap(indexReader, stq, SpanWeight.Postings.PAYLOADS); assertTrue("spans is null and it shouldn't be", spans != null); - checkSpans(spans, collector, 100, 0, 0, 0); + checkSpans(spans, 100, 0, 0, 0); } public void testSpanFirst() throws IOException { @@ -91,20 +91,19 @@ public class TestPayloadSpans extends LuceneTestCase { SpanFirstQuery sfq; match = new SpanTermQuery(new Term(PayloadHelper.FIELD, "one")); sfq = new SpanFirstQuery(match, 2); - PayloadSpanCollector collector = new PayloadSpanCollector(); Spans spans = MultiSpansWrapper.wrap(indexReader, sfq, SpanWeight.Postings.PAYLOADS); - checkSpans(spans, collector, 109, 1, 1, 1); + checkSpans(spans, 109, 1, 1, 1); //Test more complicated subclause SpanQuery[] clauses = new SpanQuery[2]; clauses[0] = new SpanTermQuery(new Term(PayloadHelper.FIELD, "one")); clauses[1] = new SpanTermQuery(new Term(PayloadHelper.FIELD, "hundred")); match = new SpanNearQuery(clauses, 0, true); sfq = new SpanFirstQuery(match, 2); - checkSpans(MultiSpansWrapper.wrap(indexReader, sfq, SpanWeight.Postings.PAYLOADS), collector, 100, 2, 1, 1); + checkSpans(MultiSpansWrapper.wrap(indexReader, sfq, SpanWeight.Postings.PAYLOADS), 100, 2, 1, 1); match = new SpanNearQuery(clauses, 0, false); sfq = new SpanFirstQuery(match, 2); - checkSpans(MultiSpansWrapper.wrap(indexReader, sfq, SpanWeight.Postings.PAYLOADS), collector, 100, 2, 1, 1); + checkSpans(MultiSpansWrapper.wrap(indexReader, sfq, SpanWeight.Postings.PAYLOADS), 100, 2, 1, 1); } @@ -127,8 +126,7 @@ public class TestPayloadSpans extends LuceneTestCase { IndexReader reader = writer.getReader(); writer.close(); - PayloadSpanCollector collector = new PayloadSpanCollector(); - checkSpans(MultiSpansWrapper.wrap(reader, snq, SpanWeight.Postings.PAYLOADS), collector, 1, new int[]{2}); + checkSpans(MultiSpansWrapper.wrap(reader, snq, SpanWeight.Postings.PAYLOADS), 1, new int[]{2}); reader.close(); directory.close(); } @@ -137,7 +135,6 @@ public class TestPayloadSpans extends LuceneTestCase { SpanTermQuery stq; Spans spans; IndexSearcher searcher = getSearcher(); - PayloadSpanCollector collector = new PayloadSpanCollector(); stq = new SpanTermQuery(new Term(PayloadHelper.FIELD, "mark")); spans = MultiSpansWrapper.wrap(searcher.getIndexReader(), stq, SpanWeight.Postings.PAYLOADS); @@ -151,7 +148,7 @@ public class TestPayloadSpans extends LuceneTestCase { spans = MultiSpansWrapper.wrap(searcher.getIndexReader(), spanNearQuery, SpanWeight.Postings.PAYLOADS); assertTrue("spans is null and it shouldn't be", spans != null); - checkSpans(spans, collector, 2, new int[]{3,3}); + checkSpans(spans, 2, new int[]{3,3}); clauses[0] = new SpanTermQuery(new Term(PayloadHelper.FIELD, "xx")); @@ -163,7 +160,7 @@ public class TestPayloadSpans extends LuceneTestCase { spans = MultiSpansWrapper.wrap(searcher.getIndexReader(), spanNearQuery, SpanWeight.Postings.PAYLOADS); assertTrue("spans is null and it shouldn't be", spans != null); - checkSpans(spans, collector, 1, new int[]{3}); + checkSpans(spans, 1, new int[]{3}); clauses = new SpanQuery[2]; @@ -184,7 +181,7 @@ public class TestPayloadSpans extends LuceneTestCase { // yy within 6 of xx within 6 of rr spans = MultiSpansWrapper.wrap(searcher.getIndexReader(), nestedSpanNearQuery, SpanWeight.Postings.PAYLOADS); assertTrue("spans is null and it shouldn't be", spans != null); - checkSpans(spans, collector, 2, new int[]{3,3}); + checkSpans(spans, 2, new int[]{3,3}); closeIndexReader.close(); directory.close(); } @@ -212,12 +209,11 @@ public class TestPayloadSpans extends LuceneTestCase { clauses3[0] = new SpanTermQuery(new Term(PayloadHelper.FIELD, "np")); clauses3[1] = snq; - PayloadSpanCollector collector = new PayloadSpanCollector(); SpanNearQuery nestedSpanNearQuery = new SpanNearQuery(clauses3, 6, false); spans = MultiSpansWrapper.wrap(searcher.getIndexReader(), nestedSpanNearQuery, SpanWeight.Postings.PAYLOADS); assertTrue("spans is null and it shouldn't be", spans != null); - checkSpans(spans, collector, 1, new int[]{3}); + checkSpans(spans, 1, new int[]{3}); closeIndexReader.close(); directory.close(); } @@ -252,10 +248,9 @@ public class TestPayloadSpans extends LuceneTestCase { SpanNearQuery nestedSpanNearQuery = new SpanNearQuery(clauses3, 6, false); - PayloadSpanCollector collector = new PayloadSpanCollector(); spans = MultiSpansWrapper.wrap(searcher.getIndexReader(), nestedSpanNearQuery, SpanWeight.Postings.PAYLOADS); assertTrue("spans is null and it shouldn't be", spans != null); - checkSpans(spans, collector, 2, new int[]{8, 8}); + checkSpans(spans, 2, new int[]{8, 8}); closeIndexReader.close(); directory.close(); } @@ -277,7 +272,7 @@ public class TestPayloadSpans extends LuceneTestCase { SpanTermQuery stq2 = new SpanTermQuery(new Term("content", "k")); SpanQuery[] sqs = { stq1, stq2 }; SpanNearQuery snq = new SpanNearQuery(sqs, 1, true); - PayloadSpanCollector collector = new PayloadSpanCollector(); + VerifyingCollector collector = new VerifyingCollector(); Spans spans = MultiSpansWrapper.wrap(is.getIndexReader(), snq, SpanWeight.Postings.PAYLOADS); TopDocs topDocs = is.search(snq, 1); @@ -287,9 +282,8 @@ public class TestPayloadSpans extends LuceneTestCase { while (spans.nextStartPosition() != Spans.NO_MORE_POSITIONS) { collector.reset(); spans.collect(collector); - Collection payloads = collector.getPayloads(); - for (final byte [] payload : payloads) { - payloadSet.add(new String(payload, StandardCharsets.UTF_8)); + for (final BytesRef payload : collector.payloads) { + payloadSet.add(Term.toString(payload)); } } } @@ -317,7 +311,7 @@ public class TestPayloadSpans extends LuceneTestCase { SpanTermQuery stq2 = new SpanTermQuery(new Term("content", "k")); SpanQuery[] sqs = { stq1, stq2 }; SpanNearQuery snq = new SpanNearQuery(sqs, 0, true); - PayloadSpanCollector collector = new PayloadSpanCollector(); + VerifyingCollector collector = new VerifyingCollector(); Spans spans = MultiSpansWrapper.wrap(is.getIndexReader(), snq, SpanWeight.Postings.PAYLOADS); TopDocs topDocs = is.search(snq, 1); @@ -327,10 +321,8 @@ public class TestPayloadSpans extends LuceneTestCase { while (spans.nextStartPosition() != Spans.NO_MORE_POSITIONS) { collector.reset(); spans.collect(collector); - Collection payloads = collector.getPayloads(); - - for (final byte [] payload : payloads) { - payloadSet.add(new String(payload, StandardCharsets.UTF_8)); + for (final BytesRef payload: collector.payloads) { + payloadSet.add(Term.toString(payload)); } } } @@ -358,20 +350,18 @@ public class TestPayloadSpans extends LuceneTestCase { SpanTermQuery stq2 = new SpanTermQuery(new Term("content", "k")); SpanQuery[] sqs = { stq1, stq2 }; SpanNearQuery snq = new SpanNearQuery(sqs, 0, true); - PayloadSpanCollector collector = new PayloadSpanCollector(); Spans spans = MultiSpansWrapper.wrap(is.getIndexReader(), snq, SpanWeight.Postings.PAYLOADS); TopDocs topDocs = is.search(snq, 1); Set payloadSet = new HashSet<>(); + VerifyingCollector collector = new VerifyingCollector(); for (int i = 0; i < topDocs.scoreDocs.length; i++) { while (spans.nextDoc() != Spans.NO_MORE_DOCS) { while (spans.nextStartPosition() != Spans.NO_MORE_POSITIONS) { collector.reset(); spans.collect(collector); - Collection payloads = collector.getPayloads(); - - for (final byte [] payload : payloads) { - payloadSet.add(new String(payload, StandardCharsets.UTF_8)); + for (final BytesRef payload : collector.payloads) { + payloadSet.add(Term.toString(payload)); } } } @@ -387,57 +377,51 @@ public class TestPayloadSpans extends LuceneTestCase { reader.close(); directory.close(); } - - public void testPayloadSpanUtil() throws Exception { - Directory directory = newDirectory(); - RandomIndexWriter writer = new RandomIndexWriter(random(), directory, - newIndexWriterConfig(new PayloadAnalyzer()).setSimilarity(similarity)); - Document doc = new Document(); - doc.add(newTextField(PayloadHelper.FIELD, "xx rr yy mm pp", Field.Store.YES)); - writer.addDocument(doc); - - IndexReader reader = writer.getReader(); - writer.close(); - IndexSearcher searcher = newSearcher(reader); + static class VerifyingCollector implements SpanCollector { - PayloadSpanUtil psu = new PayloadSpanUtil(searcher.getTopReaderContext()); - - Collection payloads = psu.getPayloadsForQuery(new TermQuery(new Term(PayloadHelper.FIELD, "rr"))); - if(VERBOSE) { - System.out.println("Num payloads:" + payloads.size()); - for (final byte [] bytes : payloads) { - System.out.println(new String(bytes, StandardCharsets.UTF_8)); + List payloads = new ArrayList<>(); + + @Override + public void collectLeaf(PostingsEnum postings, int position, Term term) throws IOException { + if (postings.getPayload() != null) { + payloads.add(BytesRef.deepCopyOf(postings.getPayload())); + } + } + + @Override + public void reset() { + payloads.clear(); + } + + public void verify(int expectedLength, int expectedFirstByte) { + for (BytesRef payload : payloads) { + assertEquals("Incorrect payload length", expectedLength, payload.length); + assertEquals("Incorrect first byte", expectedFirstByte, payload.bytes[0]); } } - reader.close(); - directory.close(); } - private void checkSpans(Spans spans, PayloadSpanCollector collector, int expectedNumSpans, int expectedNumPayloads, + private void checkSpans(Spans spans, int expectedNumSpans, int expectedNumPayloads, int expectedPayloadLength, int expectedFirstByte) throws IOException { assertTrue("spans is null and it shouldn't be", spans != null); //each position match should have a span associated with it, since there is just one underlying term query, there should //only be one entry in the span + VerifyingCollector collector = new VerifyingCollector(); int seen = 0; while (spans.nextDoc() != Spans.NO_MORE_DOCS) { while (spans.nextStartPosition() != Spans.NO_MORE_POSITIONS) { collector.reset(); spans.collect(collector); - - Collection payload = collector.getPayloads(); - assertEquals("payload size", expectedNumPayloads, payload.size()); - for (final byte [] thePayload : payload) { - assertEquals("payload length", expectedPayloadLength, thePayload.length); - assertEquals("payload first byte", expectedFirstByte, thePayload[0]); - } - + collector.verify(expectedPayloadLength, expectedFirstByte); + assertEquals("expectedNumPayloads", expectedNumPayloads, collector.payloads.size()); seen++; } } assertEquals("expectedNumSpans", expectedNumSpans, seen); } - + + private IndexSearcher getSearcher() throws Exception { directory = newDirectory(); String[] docs = new String[]{"xx rr yy mm pp","xx yy mm rr pp", "nopayload qq ss pp np", "one two three four five six seven eight nine ten eleven", "nine one two three four five six seven eight eleven ten"}; @@ -459,25 +443,16 @@ public class TestPayloadSpans extends LuceneTestCase { return searcher; } - private void checkSpans(Spans spans, PayloadSpanCollector collector, int numSpans, int[] numPayloads) throws IOException { + private void checkSpans(Spans spans, int numSpans, int[] numPayloads) throws IOException { int cnt = 0; - + VerifyingCollector collector = new VerifyingCollector(); while (spans.nextDoc() != Spans.NO_MORE_DOCS) { while (spans.nextStartPosition() != Spans.NO_MORE_POSITIONS) { if(VERBOSE) System.out.println("\nSpans Dump --"); collector.reset(); spans.collect(collector); - - Collection payload = collector.getPayloads(); - if(VERBOSE) { - System.out.println("payloads for span:" + payload.size()); - for (final byte [] bytes : payload) { - System.out.println("doc:" + spans.docID() + " s:" + spans.startPosition() + " e:" + spans.endPosition() + " " - + new String(bytes, StandardCharsets.UTF_8)); - } - } - assertEquals("payload size", numPayloads[cnt], payload.size()); + assertEquals("payload size", numPayloads[cnt], collector.payloads.size()); cnt++; } diff --git a/lucene/core/src/test/org/apache/lucene/search/payloads/TestPayloadTermQuery.java b/lucene/queries/src/test/org/apache/lucene/queries/payloads/TestPayloadTermQuery.java similarity index 99% rename from lucene/core/src/test/org/apache/lucene/search/payloads/TestPayloadTermQuery.java rename to lucene/queries/src/test/org/apache/lucene/queries/payloads/TestPayloadTermQuery.java index 5cc0927ba60..aaf3e0ae068 100644 --- a/lucene/core/src/test/org/apache/lucene/search/payloads/TestPayloadTermQuery.java +++ b/lucene/queries/src/test/org/apache/lucene/queries/payloads/TestPayloadTermQuery.java @@ -1,4 +1,4 @@ -package org.apache.lucene.search.payloads; +package org.apache.lucene.queries.payloads; /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with diff --git a/lucene/queryparser/src/java/org/apache/lucene/queryparser/xml/builders/BoostingTermBuilder.java b/lucene/queryparser/src/java/org/apache/lucene/queryparser/xml/builders/BoostingTermBuilder.java index ba169bd8a82..08ea9735018 100644 --- a/lucene/queryparser/src/java/org/apache/lucene/queryparser/xml/builders/BoostingTermBuilder.java +++ b/lucene/queryparser/src/java/org/apache/lucene/queryparser/xml/builders/BoostingTermBuilder.java @@ -3,8 +3,8 @@ package org.apache.lucene.queryparser.xml.builders; import org.apache.lucene.index.Term; import org.apache.lucene.queryparser.xml.DOMUtils; import org.apache.lucene.queryparser.xml.ParserException; -import org.apache.lucene.search.payloads.AveragePayloadFunction; -import org.apache.lucene.search.payloads.PayloadScoreQuery; +import org.apache.lucene.queries.payloads.AveragePayloadFunction; +import org.apache.lucene.queries.payloads.PayloadScoreQuery; import org.apache.lucene.search.spans.SpanBoostQuery; import org.apache.lucene.search.spans.SpanQuery; import org.apache.lucene.search.spans.SpanTermQuery; diff --git a/lucene/core/src/java/org/apache/lucene/search/payloads/PayloadSpanCollector.java b/lucene/sandbox/src/java/org/apache/lucene/payloads/PayloadSpanCollector.java similarity index 97% rename from lucene/core/src/java/org/apache/lucene/search/payloads/PayloadSpanCollector.java rename to lucene/sandbox/src/java/org/apache/lucene/payloads/PayloadSpanCollector.java index 9a8c86dd66c..690bbcc4374 100644 --- a/lucene/core/src/java/org/apache/lucene/search/payloads/PayloadSpanCollector.java +++ b/lucene/sandbox/src/java/org/apache/lucene/payloads/PayloadSpanCollector.java @@ -1,4 +1,4 @@ -package org.apache.lucene.search.payloads; +package org.apache.lucene.payloads; /* * Licensed to the Apache Software Foundation (ASF) under one or more diff --git a/lucene/core/src/java/org/apache/lucene/search/payloads/PayloadSpanUtil.java b/lucene/sandbox/src/java/org/apache/lucene/payloads/PayloadSpanUtil.java similarity index 99% rename from lucene/core/src/java/org/apache/lucene/search/payloads/PayloadSpanUtil.java rename to lucene/sandbox/src/java/org/apache/lucene/payloads/PayloadSpanUtil.java index 56fae7525d6..20b120d9af7 100644 --- a/lucene/core/src/java/org/apache/lucene/search/payloads/PayloadSpanUtil.java +++ b/lucene/sandbox/src/java/org/apache/lucene/payloads/PayloadSpanUtil.java @@ -1,4 +1,4 @@ -package org.apache.lucene.search.payloads; +package org.apache.lucene.payloads; /* * Licensed to the Apache Software Foundation (ASF) under one or more @@ -17,6 +17,12 @@ package org.apache.lucene.search.payloads; * limitations under the License. */ +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Iterator; +import java.util.List; + import org.apache.lucene.index.IndexReader; import org.apache.lucene.index.IndexReaderContext; import org.apache.lucene.index.LeafReaderContext; @@ -36,12 +42,6 @@ import org.apache.lucene.search.spans.SpanTermQuery; import org.apache.lucene.search.spans.SpanWeight; import org.apache.lucene.search.spans.Spans; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Iterator; -import java.util.List; - /** * Experimental class to get set of payloads for most standard Lucene queries. * Operates like Highlighter - IndexReader should only contain doc of interest, diff --git a/lucene/sandbox/src/java/org/apache/lucene/payloads/package-info.java b/lucene/sandbox/src/java/org/apache/lucene/payloads/package-info.java new file mode 100644 index 00000000000..b2a6bb3ad32 --- /dev/null +++ b/lucene/sandbox/src/java/org/apache/lucene/payloads/package-info.java @@ -0,0 +1,21 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Experimental classes for interacting with payloads + */ +package org.apache.lucene.payloads; diff --git a/lucene/sandbox/src/test/org/apache/lucene/payloads/TestPayloadSpanUtil.java b/lucene/sandbox/src/test/org/apache/lucene/payloads/TestPayloadSpanUtil.java new file mode 100644 index 00000000000..b08164475a4 --- /dev/null +++ b/lucene/sandbox/src/test/org/apache/lucene/payloads/TestPayloadSpanUtil.java @@ -0,0 +1,130 @@ +package org.apache.lucene.payloads; + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import java.io.IOException; +import java.nio.charset.StandardCharsets; +import java.util.Collection; +import java.util.HashSet; +import java.util.Set; + +import org.apache.lucene.analysis.Analyzer; +import org.apache.lucene.analysis.MockTokenizer; +import org.apache.lucene.analysis.TokenFilter; +import org.apache.lucene.analysis.TokenStream; +import org.apache.lucene.analysis.Tokenizer; +import org.apache.lucene.analysis.tokenattributes.CharTermAttribute; +import org.apache.lucene.analysis.tokenattributes.PayloadAttribute; +import org.apache.lucene.analysis.tokenattributes.PositionIncrementAttribute; +import org.apache.lucene.document.Document; +import org.apache.lucene.document.Field; +import org.apache.lucene.index.IndexReader; +import org.apache.lucene.index.RandomIndexWriter; +import org.apache.lucene.index.Term; +import org.apache.lucene.search.IndexSearcher; +import org.apache.lucene.search.TermQuery; +import org.apache.lucene.search.similarities.ClassicSimilarity; +import org.apache.lucene.store.Directory; +import org.apache.lucene.util.BytesRef; +import org.apache.lucene.util.LuceneTestCase; + +public class TestPayloadSpanUtil extends LuceneTestCase { + + public static final String FIELD = "f"; + + public void testPayloadSpanUtil() throws Exception { + Directory directory = newDirectory(); + RandomIndexWriter writer = new RandomIndexWriter(random(), directory, + newIndexWriterConfig(new PayloadAnalyzer()).setSimilarity(new ClassicSimilarity())); + + Document doc = new Document(); + doc.add(newTextField(FIELD, "xx rr yy mm pp", Field.Store.YES)); + writer.addDocument(doc); + + IndexReader reader = writer.getReader(); + writer.close(); + IndexSearcher searcher = newSearcher(reader); + + PayloadSpanUtil psu = new PayloadSpanUtil(searcher.getTopReaderContext()); + + Collection payloads = psu.getPayloadsForQuery(new TermQuery(new Term(FIELD, "rr"))); + if(VERBOSE) { + System.out.println("Num payloads:" + payloads.size()); + for (final byte [] bytes : payloads) { + System.out.println(new String(bytes, StandardCharsets.UTF_8)); + } + } + reader.close(); + directory.close(); + } + + final class PayloadAnalyzer extends Analyzer { + + @Override + public TokenStreamComponents createComponents(String fieldName) { + Tokenizer result = new MockTokenizer(MockTokenizer.SIMPLE, true); + return new TokenStreamComponents(result, new PayloadFilter(result)); + } + } + + final class PayloadFilter extends TokenFilter { + Set entities = new HashSet<>(); + Set nopayload = new HashSet<>(); + int pos; + PayloadAttribute payloadAtt; + CharTermAttribute termAtt; + PositionIncrementAttribute posIncrAtt; + + public PayloadFilter(TokenStream input) { + super(input); + pos = 0; + entities.add("xx"); + entities.add("one"); + nopayload.add("nopayload"); + nopayload.add("np"); + termAtt = addAttribute(CharTermAttribute.class); + posIncrAtt = addAttribute(PositionIncrementAttribute.class); + payloadAtt = addAttribute(PayloadAttribute.class); + } + + @Override + public boolean incrementToken() throws IOException { + if (input.incrementToken()) { + String token = termAtt.toString(); + + if (!nopayload.contains(token)) { + if (entities.contains(token)) { + payloadAtt.setPayload(new BytesRef(token + ":Entity:"+ pos )); + } else { + payloadAtt.setPayload(new BytesRef(token + ":Noise:" + pos )); + } + } + pos += posIncrAtt.getPositionIncrement(); + return true; + } + return false; + } + + @Override + public void reset() throws IOException { + super.reset(); + this.pos = 0; + } + } + +} diff --git a/lucene/core/src/test/org/apache/lucene/search/spans/MultiSpansWrapper.java b/lucene/test-framework/src/java/org/apache/lucene/search/spans/MultiSpansWrapper.java similarity index 100% rename from lucene/core/src/test/org/apache/lucene/search/spans/MultiSpansWrapper.java rename to lucene/test-framework/src/java/org/apache/lucene/search/spans/MultiSpansWrapper.java index 2197ea17f6f..af580c74c60 100644 --- a/lucene/core/src/test/org/apache/lucene/search/spans/MultiSpansWrapper.java +++ b/lucene/test-framework/src/java/org/apache/lucene/search/spans/MultiSpansWrapper.java @@ -17,14 +17,14 @@ package org.apache.lucene.search.spans; * limitations under the License. */ +import java.io.IOException; + import org.apache.lucene.index.IndexReader; import org.apache.lucene.index.LeafReader; import org.apache.lucene.index.LeafReaderContext; import org.apache.lucene.index.SlowCompositeReaderWrapper; import org.apache.lucene.search.IndexSearcher; -import java.io.IOException; - /** * * A wrapper to perform span operations on a non-leaf reader context diff --git a/solr/core/src/test/org/apache/solr/highlight/HighlighterTest.java b/solr/core/src/test/org/apache/solr/highlight/HighlighterTest.java index 7566f5d61cd..1519c7f4cc7 100644 --- a/solr/core/src/test/org/apache/solr/highlight/HighlighterTest.java +++ b/solr/core/src/test/org/apache/solr/highlight/HighlighterTest.java @@ -28,7 +28,7 @@ import org.apache.lucene.analysis.TokenStream; import org.apache.lucene.analysis.core.WhitespaceAnalyzer; import org.apache.lucene.index.Term; import org.apache.lucene.search.Query; -import org.apache.lucene.search.payloads.SpanPayloadCheckQuery; +import org.apache.lucene.queries.payloads.SpanPayloadCheckQuery; import org.apache.lucene.search.spans.SpanTermQuery; import org.apache.lucene.util.BytesRef; import org.apache.solr.SolrTestCaseJ4;