From 4c71456349e5370543208da0649c1adbb5ff29ed Mon Sep 17 00:00:00 2001 From: Matthijs Brouwer <matthijs@brouwer.info> Date: Fri, 22 Mar 2019 16:45:22 +0100 Subject: [PATCH] upgrade to version 8.0.0 --- .gitignore | 1 + src/main/java/mtas/codec/MtasCodec.java | 2 +- .../java/mtas/codec/MtasFieldsConsumer.java | 9 +-- .../java/mtas/codec/util/CodecCollector.java | 3 +- src/main/java/mtas/codec/util/CodecUtil.java | 3 +- .../cql/util/MtasCQLParserGroupQuery.java | 5 +- .../util/MtasCQLParserWordPositionQuery.java | 5 +- .../cql/util/MtasCQLParserWordQuery.java | 5 +- .../util/MtasSimpleParserWordQuery.java | 5 +- .../java/mtas/queries/MtasScoreProvider.java | 45 --------------- .../java/mtas/queries/MtasScoreQuery.java | 55 ------------------- src/main/java/mtas/search/MtasCollector.java | 16 ++---- .../search/similarities/MtasSimScorer.java | 27 +-------- .../mtas/search/spans/MtasSpanAndQuery.java | 7 ++- .../search/spans/MtasSpanContainingQuery.java | 5 +- .../mtas/search/spans/MtasSpanEndQuery.java | 11 ++-- .../search/spans/MtasSpanFollowedByQuery.java | 23 ++++---- .../spans/MtasSpanFullyAlignedWithQuery.java | 23 ++++---- .../spans/MtasSpanIntersectingQuery.java | 23 ++++---- .../search/spans/MtasSpanMatchAllQuery.java | 16 +++--- .../search/spans/MtasSpanMatchNoneQuery.java | 14 +++-- .../mtas/search/spans/MtasSpanNotQuery.java | 23 ++++---- .../mtas/search/spans/MtasSpanOrQuery.java | 5 +- .../search/spans/MtasSpanPositionQuery.java | 14 +++-- .../search/spans/MtasSpanPrecededByQuery.java | 23 ++++---- .../search/spans/MtasSpanPrefixQuery.java | 5 +- .../search/spans/MtasSpanRecurrenceQuery.java | 17 +++--- .../search/spans/MtasSpanRegexpQuery.java | 5 +- .../search/spans/MtasSpanSequenceQuery.java | 23 ++++---- .../mtas/search/spans/MtasSpanStartQuery.java | 11 ++-- .../mtas/search/spans/MtasSpanTermQuery.java | 5 +- .../search/spans/MtasSpanWildcardQuery.java | 5 +- .../search/spans/MtasSpanWithinQuery.java | 5 +- ...MtasDisabledTwoPhaseIteratorSpanQuery.java | 17 +++--- .../spans/util/MtasExpandSpanQuery.java | 17 +++--- .../spans/util/MtasExtendedSpanTermQuery.java | 33 +++++------ .../util/MtasMaximumExpandSpanQuery.java | 17 +++--- .../util/MtasSpanUniquePositionQuery.java | 15 ++--- .../search/spans/util/MtasSpanWeight.java | 4 +- .../search/MtasSearchTestConsistency.java | 3 +- ...sSolrTestDistributedSearchConsistency.java | 3 +- 41 files changed, 232 insertions(+), 321 deletions(-) delete mode 100644 src/main/java/mtas/queries/MtasScoreProvider.java delete mode 100644 src/main/java/mtas/queries/MtasScoreQuery.java diff --git a/.gitignore b/.gitignore index 0d43b8e..e22708b 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,7 @@ publications target/ solr-*/ jetty-*/ +alpn/ /data/ examples/ demo/ diff --git a/src/main/java/mtas/codec/MtasCodec.java b/src/main/java/mtas/codec/MtasCodec.java index 3dcfbae..3354e10 100644 --- a/src/main/java/mtas/codec/MtasCodec.java +++ b/src/main/java/mtas/codec/MtasCodec.java @@ -70,7 +70,7 @@ public class MtasCodec extends Codec { || (defaultPostingsFormat instanceof PerFieldPostingsFormat)) { // fallback option return new MtasCodecPostingsFormat( - PostingsFormat.forName("Lucene70")); + PostingsFormat.forName("Lucene80")); } else { return new MtasCodecPostingsFormat(defaultPostingsFormat); } diff --git a/src/main/java/mtas/codec/MtasFieldsConsumer.java b/src/main/java/mtas/codec/MtasFieldsConsumer.java index f930a21..f18a6e7 100644 --- a/src/main/java/mtas/codec/MtasFieldsConsumer.java +++ b/src/main/java/mtas/codec/MtasFieldsConsumer.java @@ -30,6 +30,7 @@ import org.apache.commons.logging.LogFactory; import org.apache.lucene.codecs.CodecUtil; import org.apache.lucene.codecs.FieldsConsumer; import org.apache.lucene.codecs.FieldsProducer; +import org.apache.lucene.codecs.NormsProducer; import org.apache.lucene.index.FieldInfo; import org.apache.lucene.index.FieldInfos; import org.apache.lucene.index.Fields; @@ -671,7 +672,7 @@ public class MtasFieldsConsumer extends FieldsConsumer { * MergeState) */ @Override - public void merge(MergeState mergeState) throws IOException { + public void merge(MergeState mergeState, NormsProducer norms) throws IOException { final List<Fields> fields = new ArrayList<>(); final List<ReaderSlice> slices = new ArrayList<>(); @@ -690,7 +691,7 @@ public class MtasFieldsConsumer extends FieldsConsumer { Fields mergedFields = new MappedMultiFields(mergeState, new MultiFields(fields.toArray(Fields.EMPTY_ARRAY), slices.toArray(ReaderSlice.EMPTY_ARRAY))); - write(mergedFields); + write(mergedFields, norms); } /* @@ -700,8 +701,8 @@ public class MtasFieldsConsumer extends FieldsConsumer { * Fields ) */ @Override - public void write(Fields fields) throws IOException { - delegateFieldsConsumer.write(fields); + public void write(Fields fields, NormsProducer norms) throws IOException { + delegateFieldsConsumer.write(fields, norms); write(state.fieldInfos, fields); } diff --git a/src/main/java/mtas/codec/util/CodecCollector.java b/src/main/java/mtas/codec/util/CodecCollector.java index d768966..9f44f6a 100644 --- a/src/main/java/mtas/codec/util/CodecCollector.java +++ b/src/main/java/mtas/codec/util/CodecCollector.java @@ -85,6 +85,7 @@ import org.apache.lucene.index.Terms; import org.apache.lucene.index.TermsEnum; import org.apache.lucene.search.DocIdSetIterator; import org.apache.lucene.search.IndexSearcher; +import org.apache.lucene.search.ScoreMode; import org.apache.lucene.search.spans.SpanWeight; import org.apache.lucene.search.spans.Spans; import org.apache.lucene.util.Bits; @@ -1032,7 +1033,7 @@ public class CodecCollector { MtasSpanQuery queryHit = createQueryFromGroupHit(prefixes, field, hit); if (queryHit != null) { MtasSpanQuery queryHitRewritten = queryHit.rewrite(reader); - SpanWeight weight = queryHitRewritten.createWeight(searcher, false, boost); + SpanWeight weight = queryHitRewritten.createWeight(searcher, ScoreMode.COMPLETE_NO_SCORES, boost); Spans spans = weight.getSpans(lrc, SpanWeight.Postings.POSITIONS); if (spans != null) { list.put(hit, spans); diff --git a/src/main/java/mtas/codec/util/CodecUtil.java b/src/main/java/mtas/codec/util/CodecUtil.java index 4368be7..c61b68f 100644 --- a/src/main/java/mtas/codec/util/CodecUtil.java +++ b/src/main/java/mtas/codec/util/CodecUtil.java @@ -21,6 +21,7 @@ import mtas.codec.util.CodecComponent.ComponentCollection; import org.apache.lucene.index.FieldInfo; import org.apache.lucene.index.IndexReader; import org.apache.lucene.search.IndexSearcher; +import org.apache.lucene.search.ScoreMode; import org.apache.lucene.search.spans.SpanWeight; /** @@ -254,7 +255,7 @@ public class CodecUtil { final float boost = 0; for (MtasSpanQuery sq : fieldStats.spanQueryList) { spansQueryWeight.put(sq, ((MtasSpanQuery) sq.rewrite(reader)) - .createWeight(searcher, false, boost)); + .createWeight(searcher, ScoreMode.COMPLETE_NO_SCORES, boost)); } } // collect diff --git a/src/main/java/mtas/parser/cql/util/MtasCQLParserGroupQuery.java b/src/main/java/mtas/parser/cql/util/MtasCQLParserGroupQuery.java index 48627e1..e089821 100644 --- a/src/main/java/mtas/parser/cql/util/MtasCQLParserGroupQuery.java +++ b/src/main/java/mtas/parser/cql/util/MtasCQLParserGroupQuery.java @@ -13,6 +13,7 @@ import mtas.search.spans.util.MtasSpanQuery; import org.apache.lucene.index.IndexReader; import org.apache.lucene.index.Term; import org.apache.lucene.search.IndexSearcher; +import org.apache.lucene.search.ScoreMode; import org.apache.lucene.search.spans.SpanWeight; /** @@ -124,9 +125,9 @@ public class MtasCQLParserGroupQuery extends MtasSpanQuery { * search.IndexSearcher, boolean) */ @Override - public SpanWeight createWeight(IndexSearcher searcher, boolean needsScores, float boost) + public SpanWeight createWeight(IndexSearcher searcher, ScoreMode scoreMode, float boost) throws IOException { - return query.createWeight(searcher, needsScores, boost); + return query.createWeight(searcher, scoreMode, boost); } /* diff --git a/src/main/java/mtas/parser/cql/util/MtasCQLParserWordPositionQuery.java b/src/main/java/mtas/parser/cql/util/MtasCQLParserWordPositionQuery.java index 8166887..a10e7f5 100644 --- a/src/main/java/mtas/parser/cql/util/MtasCQLParserWordPositionQuery.java +++ b/src/main/java/mtas/parser/cql/util/MtasCQLParserWordPositionQuery.java @@ -9,6 +9,7 @@ import mtas.search.spans.util.MtasSpanQuery; import org.apache.lucene.index.IndexReader; import org.apache.lucene.index.Term; import org.apache.lucene.search.IndexSearcher; +import org.apache.lucene.search.ScoreMode; import org.apache.lucene.search.spans.SpanWeight; /** @@ -76,9 +77,9 @@ public class MtasCQLParserWordPositionQuery extends MtasSpanQuery { * search.IndexSearcher, boolean) */ @Override - public SpanWeight createWeight(IndexSearcher searcher, boolean needsScores, float boost) + public SpanWeight createWeight(IndexSearcher searcher, ScoreMode scoreMode, float boost) throws IOException { - return query.createWeight(searcher, needsScores, boost); + return query.createWeight(searcher, scoreMode, boost); } /* diff --git a/src/main/java/mtas/parser/cql/util/MtasCQLParserWordQuery.java b/src/main/java/mtas/parser/cql/util/MtasCQLParserWordQuery.java index d53a281..87d076f 100644 --- a/src/main/java/mtas/parser/cql/util/MtasCQLParserWordQuery.java +++ b/src/main/java/mtas/parser/cql/util/MtasCQLParserWordQuery.java @@ -18,6 +18,7 @@ import mtas.search.spans.util.MtasSpanQuery; import org.apache.lucene.index.IndexReader; import org.apache.lucene.index.Term; import org.apache.lucene.search.IndexSearcher; +import org.apache.lucene.search.ScoreMode; import org.apache.lucene.search.spans.SpanWeight; /** @@ -161,9 +162,9 @@ public class MtasCQLParserWordQuery extends MtasSpanQuery { * search.IndexSearcher, boolean) */ @Override - public SpanWeight createWeight(IndexSearcher searcher, boolean needsScores, float boost) + public SpanWeight createWeight(IndexSearcher searcher, ScoreMode scoreMode, float boost) throws IOException { - return query.createWeight(searcher, needsScores, boost); + return query.createWeight(searcher, scoreMode, boost); } /* diff --git a/src/main/java/mtas/parser/simple/util/MtasSimpleParserWordQuery.java b/src/main/java/mtas/parser/simple/util/MtasSimpleParserWordQuery.java index 08b19a2..635c00c 100644 --- a/src/main/java/mtas/parser/simple/util/MtasSimpleParserWordQuery.java +++ b/src/main/java/mtas/parser/simple/util/MtasSimpleParserWordQuery.java @@ -14,6 +14,7 @@ import mtas.search.spans.util.MtasSpanQuery; import org.apache.lucene.index.IndexReader; import org.apache.lucene.index.Term; import org.apache.lucene.search.IndexSearcher; +import org.apache.lucene.search.ScoreMode; import org.apache.lucene.search.spans.SpanWeight; /** @@ -98,8 +99,8 @@ public class MtasSimpleParserWordQuery extends MtasSpanQuery { * search.IndexSearcher, boolean) */ @Override - public SpanWeight createWeight(IndexSearcher searcher, boolean needsScores, float boost) throws IOException { - return query.createWeight(searcher, needsScores, boost); + public SpanWeight createWeight(IndexSearcher searcher, ScoreMode scoreMode, float boost) throws IOException { + return query.createWeight(searcher, scoreMode, boost); } /* diff --git a/src/main/java/mtas/queries/MtasScoreProvider.java b/src/main/java/mtas/queries/MtasScoreProvider.java deleted file mode 100644 index c0388b6..0000000 --- a/src/main/java/mtas/queries/MtasScoreProvider.java +++ /dev/null @@ -1,45 +0,0 @@ -package mtas.queries; - -import java.io.IOException; - -import org.apache.lucene.index.LeafReaderContext; -import org.apache.lucene.queries.CustomScoreProvider; - -/** - * The Class MtasScoreProvider. - */ -public class MtasScoreProvider extends CustomScoreProvider { - - /** - * Instantiates a new mtas score provider. - * - * @param context the context - */ - public MtasScoreProvider(LeafReaderContext context) { - super(context); - } - - /* - * (non-Javadoc) - * - * @see org.apache.lucene.queries.CustomScoreProvider#customScore(int, float, - * float) - */ - @Override - public float customScore(int doc, float subQueryScore, float valSrcScore) { - return (float) 0.0; - } - - /* - * (non-Javadoc) - * - * @see org.apache.lucene.queries.CustomScoreProvider#customScore(int, float, - * float[]) - */ - @Override - public float customScore(int doc, float subQueryScore, float[] valSrcScores) - throws IOException { - return (float) 0.0; - } - -} diff --git a/src/main/java/mtas/queries/MtasScoreQuery.java b/src/main/java/mtas/queries/MtasScoreQuery.java deleted file mode 100644 index b13c2de..0000000 --- a/src/main/java/mtas/queries/MtasScoreQuery.java +++ /dev/null @@ -1,55 +0,0 @@ -package mtas.queries; - -import org.apache.lucene.index.LeafReaderContext; -import org.apache.lucene.queries.CustomScoreProvider; -import org.apache.lucene.queries.CustomScoreQuery; -import org.apache.lucene.queries.function.FunctionQuery; -import org.apache.lucene.search.Query; - -/** - * The Class MtasScoreQuery. - */ -public class MtasScoreQuery extends CustomScoreQuery { - - /** - * Instantiates a new mtas score query. - * - * @param subQuery the sub query - */ - public MtasScoreQuery(Query subQuery) { - super(subQuery); - } - - /** - * Instantiates a new mtas score query. - * - * @param subQuery the sub query - * @param scoringQuery the scoring query - */ - public MtasScoreQuery(Query subQuery, FunctionQuery scoringQuery) { - super(subQuery, scoringQuery); - } - - /** - * Instantiates a new mtas score query. - * - * @param subQuery the sub query - * @param scoringQueries the scoring queries - */ - public MtasScoreQuery(Query subQuery, FunctionQuery... scoringQueries) { - super(subQuery, scoringQueries); - } - - /* - * (non-Javadoc) - * - * @see org.apache.lucene.queries.CustomScoreQuery#getCustomScoreProvider(org. - * apache.lucene.index.LeafReaderContext) - */ - @Override - public CustomScoreProvider getCustomScoreProvider( - final LeafReaderContext context) { - return new MtasScoreProvider(context); - } - -} diff --git a/src/main/java/mtas/search/MtasCollector.java b/src/main/java/mtas/search/MtasCollector.java index 702a4a9..a25177e 100644 --- a/src/main/java/mtas/search/MtasCollector.java +++ b/src/main/java/mtas/search/MtasCollector.java @@ -3,6 +3,7 @@ package mtas.search; import java.io.IOException; import org.apache.lucene.index.LeafReaderContext; +import org.apache.lucene.search.ScoreMode; import org.apache.lucene.search.SimpleCollector; /** @@ -10,16 +11,6 @@ import org.apache.lucene.search.SimpleCollector; */ public class MtasCollector extends SimpleCollector { - /* - * (non-Javadoc) - * - * @see org.apache.lucene.search.Collector#needsScores() - */ - @Override - public boolean needsScores() { - return false; - } - /* * (non-Javadoc) * @@ -42,4 +33,9 @@ public class MtasCollector extends SimpleCollector { // System.out.println("Mtas collector voor doc "+doc); } + @Override + public ScoreMode scoreMode() { + return ScoreMode.COMPLETE_NO_SCORES; + } + } diff --git a/src/main/java/mtas/search/similarities/MtasSimScorer.java b/src/main/java/mtas/search/similarities/MtasSimScorer.java index 5a7fca5..32b7ffd 100644 --- a/src/main/java/mtas/search/similarities/MtasSimScorer.java +++ b/src/main/java/mtas/search/similarities/MtasSimScorer.java @@ -1,7 +1,6 @@ package mtas.search.similarities; import org.apache.lucene.search.similarities.Similarity.SimScorer; -import org.apache.lucene.util.BytesRef; /** * The Class MtasSimScorer. @@ -15,31 +14,9 @@ public class MtasSimScorer extends SimScorer { * float) */ @Override - public float score(int doc, float freq) { - return 0; - } - - /* - * (non-Javadoc) - * - * @see org.apache.lucene.search.similarities.Similarity.SimScorer# - * computeSlopFactor(int) - */ - @Override - public float computeSlopFactor(int distance) { - return 0; - } - - /* - * (non-Javadoc) - * - * @see org.apache.lucene.search.similarities.Similarity.SimScorer# - * computePayloadFactor(int, int, int, org.apache.lucene.util.BytesRef) - */ - @Override - public float computePayloadFactor(int doc, int start, int end, - BytesRef payload) { + public float score(float freq, long norm) { return 0; } + } diff --git a/src/main/java/mtas/search/spans/MtasSpanAndQuery.java b/src/main/java/mtas/search/spans/MtasSpanAndQuery.java index ffb71dd..22c9a16 100644 --- a/src/main/java/mtas/search/spans/MtasSpanAndQuery.java +++ b/src/main/java/mtas/search/spans/MtasSpanAndQuery.java @@ -6,6 +6,7 @@ import java.util.Objects; import org.apache.lucene.index.IndexReader; import org.apache.lucene.search.IndexSearcher; +import org.apache.lucene.search.ScoreMode; import org.apache.lucene.search.spans.SpanNearQuery; import org.apache.lucene.search.spans.SpanWeight; @@ -78,11 +79,11 @@ public class MtasSpanAndQuery extends MtasSpanQuery { * search.IndexSearcher, boolean) */ @Override - public SpanWeight createWeight(IndexSearcher searcher, boolean needsScores, float boost) + public SpanWeight createWeight(IndexSearcher searcher, ScoreMode scoreMode, float boost) throws IOException { - return baseQuery.createWeight(searcher, needsScores, boost); + return baseQuery.createWeight(searcher, scoreMode, boost); } - + /* * (non-Javadoc) * diff --git a/src/main/java/mtas/search/spans/MtasSpanContainingQuery.java b/src/main/java/mtas/search/spans/MtasSpanContainingQuery.java index 701d2a4..41e155a 100644 --- a/src/main/java/mtas/search/spans/MtasSpanContainingQuery.java +++ b/src/main/java/mtas/search/spans/MtasSpanContainingQuery.java @@ -4,6 +4,7 @@ import java.io.IOException; import org.apache.lucene.index.IndexReader; import org.apache.lucene.search.IndexSearcher; +import org.apache.lucene.search.ScoreMode; import org.apache.lucene.search.spans.SpanContainingQuery; import org.apache.lucene.search.spans.SpanWeight; @@ -83,9 +84,9 @@ public class MtasSpanContainingQuery extends MtasSpanQuery { * search.IndexSearcher, boolean) */ @Override - public SpanWeight createWeight(IndexSearcher searcher, boolean needsScores, float boost) + public SpanWeight createWeight(IndexSearcher searcher, ScoreMode scoreMode, float boost) throws IOException { - return baseQuery.createWeight(searcher, needsScores, boost); + return baseQuery.createWeight(searcher, scoreMode, boost); } /* diff --git a/src/main/java/mtas/search/spans/MtasSpanEndQuery.java b/src/main/java/mtas/search/spans/MtasSpanEndQuery.java index 4e3f69c..031f851 100644 --- a/src/main/java/mtas/search/spans/MtasSpanEndQuery.java +++ b/src/main/java/mtas/search/spans/MtasSpanEndQuery.java @@ -8,8 +8,9 @@ import java.util.Set; import org.apache.lucene.index.IndexReader; import org.apache.lucene.index.LeafReaderContext; import org.apache.lucene.index.Term; -import org.apache.lucene.index.TermContext; +import org.apache.lucene.index.TermStates; import org.apache.lucene.search.IndexSearcher; +import org.apache.lucene.search.ScoreMode; import org.apache.lucene.search.spans.SpanQuery; import org.apache.lucene.search.spans.SpanWeight; import mtas.search.spans.util.MtasSpanQuery; @@ -91,9 +92,9 @@ public class MtasSpanEndQuery extends MtasSpanQuery { */ @Override public MtasSpanWeight createWeight(IndexSearcher searcher, - boolean needsScores, float boost) throws IOException { + ScoreMode scoreMode, float boost) throws IOException { SpanWeight spanWeight = ((SpanQuery) searcher.rewrite(clause)) - .createWeight(searcher, needsScores, boost); + .createWeight(searcher, scoreMode, boost); return new SpanTermWeight(spanWeight, searcher, boost); } @@ -126,8 +127,8 @@ public class MtasSpanEndQuery extends MtasSpanQuery { * Map) */ @Override - public void extractTermContexts(Map<Term, TermContext> contexts) { - spanWeight.extractTermContexts(contexts); + public void extractTermStates(Map<Term, TermStates> contexts) { + spanWeight.extractTermStates(contexts); } /* diff --git a/src/main/java/mtas/search/spans/MtasSpanFollowedByQuery.java b/src/main/java/mtas/search/spans/MtasSpanFollowedByQuery.java index 4742451..fe2e893 100644 --- a/src/main/java/mtas/search/spans/MtasSpanFollowedByQuery.java +++ b/src/main/java/mtas/search/spans/MtasSpanFollowedByQuery.java @@ -10,9 +10,10 @@ import java.util.Set; import org.apache.lucene.index.IndexReader; import org.apache.lucene.index.LeafReaderContext; import org.apache.lucene.index.Term; -import org.apache.lucene.index.TermContext; +import org.apache.lucene.index.TermStates; import org.apache.lucene.index.Terms; import org.apache.lucene.search.IndexSearcher; +import org.apache.lucene.search.ScoreMode; import org.apache.lucene.search.spans.SpanWeight; import org.apache.lucene.search.spans.Spans; @@ -75,21 +76,21 @@ public class MtasSpanFollowedByQuery extends MtasSpanQuery { */ @Override public MtasSpanWeight createWeight(IndexSearcher searcher, - boolean needsScores, float boost) throws IOException { + ScoreMode scoreMode, float boost) throws IOException { if (q1 == null || q2 == null) { return null; } else { MtasSpanFollowedByQueryWeight w1 = new MtasSpanFollowedByQueryWeight( - q1.createWeight(searcher, needsScores, boost)); + q1.createWeight(searcher, scoreMode, boost)); MtasSpanFollowedByQueryWeight w2 = new MtasSpanFollowedByQueryWeight( - q2.createWeight(searcher, needsScores, boost)); + q2.createWeight(searcher, scoreMode, boost)); // subWeights List<MtasSpanFollowedByQueryWeight> subWeights = new ArrayList<>(); subWeights.add(w1); subWeights.add(w2); // return return new SpanFollowedByWeight(w1, w2, searcher, - needsScores ? getTermContexts(subWeights) : null, boost); + scoreMode.needsScores() ? getTermStates(subWeights) : null, boost); } } @@ -99,13 +100,13 @@ public class MtasSpanFollowedByQuery extends MtasSpanQuery { * @param items the items * @return the term contexts */ - protected Map<Term, TermContext> getTermContexts( + protected Map<Term, TermStates> getTermStates( List<MtasSpanFollowedByQueryWeight> items) { List<SpanWeight> weights = new ArrayList<>(); for (MtasSpanFollowedByQueryWeight item : items) { weights.add(item.spanWeight); } - return getTermContexts(weights); + return getTermStates(weights); } /* @@ -213,7 +214,7 @@ public class MtasSpanFollowedByQuery extends MtasSpanQuery { */ public SpanFollowedByWeight(MtasSpanFollowedByQueryWeight w1, MtasSpanFollowedByQueryWeight w2, IndexSearcher searcher, - Map<Term, TermContext> terms, float boost) throws IOException { + Map<Term, TermStates> terms, float boost) throws IOException { super(MtasSpanFollowedByQuery.this, searcher, terms, boost); this.w1 = w1; this.w2 = w2; @@ -227,9 +228,9 @@ public class MtasSpanFollowedByQuery extends MtasSpanQuery { * Map) */ @Override - public void extractTermContexts(Map<Term, TermContext> contexts) { - w1.spanWeight.extractTermContexts(contexts); - w2.spanWeight.extractTermContexts(contexts); + public void extractTermStates(Map<Term, TermStates> contexts) { + w1.spanWeight.extractTermStates(contexts); + w2.spanWeight.extractTermStates(contexts); } /* diff --git a/src/main/java/mtas/search/spans/MtasSpanFullyAlignedWithQuery.java b/src/main/java/mtas/search/spans/MtasSpanFullyAlignedWithQuery.java index 6558330..8eb0c7f 100644 --- a/src/main/java/mtas/search/spans/MtasSpanFullyAlignedWithQuery.java +++ b/src/main/java/mtas/search/spans/MtasSpanFullyAlignedWithQuery.java @@ -10,9 +10,10 @@ import java.util.Set; import org.apache.lucene.index.IndexReader; import org.apache.lucene.index.LeafReaderContext; import org.apache.lucene.index.Term; -import org.apache.lucene.index.TermContext; +import org.apache.lucene.index.TermStates; import org.apache.lucene.index.Terms; import org.apache.lucene.search.IndexSearcher; +import org.apache.lucene.search.ScoreMode; import org.apache.lucene.search.spans.SpanWeight; import org.apache.lucene.search.spans.Spans; import mtas.search.spans.util.MtasSpanQuery; @@ -74,21 +75,21 @@ public class MtasSpanFullyAlignedWithQuery extends MtasSpanQuery { */ @Override public MtasSpanWeight createWeight(IndexSearcher searcher, - boolean needsScores, float boost) throws IOException { + ScoreMode scoreMode, float boost) throws IOException { if (q1 == null || q2 == null) { return null; } else { MtasSpanFullyAlignedWithQueryWeight w1 = new MtasSpanFullyAlignedWithQueryWeight( - q1.createWeight(searcher, needsScores, boost)); + q1.createWeight(searcher, scoreMode, boost)); MtasSpanFullyAlignedWithQueryWeight w2 = new MtasSpanFullyAlignedWithQueryWeight( - q2.createWeight(searcher, needsScores, boost)); + q2.createWeight(searcher, scoreMode, boost)); // subWeights List<MtasSpanFullyAlignedWithQueryWeight> subWeights = new ArrayList<>(); subWeights.add(w1); subWeights.add(w2); // return return new SpanFullyAlignedWithWeight(w1, w2, searcher, - needsScores ? getTermContexts(subWeights) : null, boost); + scoreMode.needsScores() ? getTermStates(subWeights) : null, boost); } } @@ -98,13 +99,13 @@ public class MtasSpanFullyAlignedWithQuery extends MtasSpanQuery { * @param items the items * @return the term contexts */ - protected Map<Term, TermContext> getTermContexts( + protected Map<Term, TermStates> getTermStates( List<MtasSpanFullyAlignedWithQueryWeight> items) { List<SpanWeight> weights = new ArrayList<>(); for (MtasSpanFullyAlignedWithQueryWeight item : items) { weights.add(item.spanWeight); } - return getTermContexts(weights); + return getTermStates(weights); } /* @@ -232,7 +233,7 @@ public class MtasSpanFullyAlignedWithQuery extends MtasSpanQuery { */ public SpanFullyAlignedWithWeight(MtasSpanFullyAlignedWithQueryWeight w1, MtasSpanFullyAlignedWithQueryWeight w2, IndexSearcher searcher, - Map<Term, TermContext> terms, float boost) throws IOException { + Map<Term, TermStates> terms, float boost) throws IOException { super(MtasSpanFullyAlignedWithQuery.this, searcher, terms, boost); this.w1 = w1; this.w2 = w2; @@ -246,9 +247,9 @@ public class MtasSpanFullyAlignedWithQuery extends MtasSpanQuery { * Map) */ @Override - public void extractTermContexts(Map<Term, TermContext> contexts) { - w1.spanWeight.extractTermContexts(contexts); - w2.spanWeight.extractTermContexts(contexts); + public void extractTermStates(Map<Term, TermStates> contexts) { + w1.spanWeight.extractTermStates(contexts); + w2.spanWeight.extractTermStates(contexts); } /* diff --git a/src/main/java/mtas/search/spans/MtasSpanIntersectingQuery.java b/src/main/java/mtas/search/spans/MtasSpanIntersectingQuery.java index 3a513d1..1f80772 100644 --- a/src/main/java/mtas/search/spans/MtasSpanIntersectingQuery.java +++ b/src/main/java/mtas/search/spans/MtasSpanIntersectingQuery.java @@ -10,9 +10,10 @@ import java.util.Set; import org.apache.lucene.index.IndexReader; import org.apache.lucene.index.LeafReaderContext; import org.apache.lucene.index.Term; -import org.apache.lucene.index.TermContext; +import org.apache.lucene.index.TermStates; import org.apache.lucene.index.Terms; import org.apache.lucene.search.IndexSearcher; +import org.apache.lucene.search.ScoreMode; import org.apache.lucene.search.spans.SpanWeight; import org.apache.lucene.search.spans.Spans; import mtas.search.spans.util.MtasSpanQuery; @@ -74,21 +75,21 @@ public class MtasSpanIntersectingQuery extends MtasSpanQuery { */ @Override public MtasSpanWeight createWeight(IndexSearcher searcher, - boolean needsScores, float boost) throws IOException { + ScoreMode scoreMode, float boost) throws IOException { if (q1 == null || q2 == null) { return null; } else { MtasSpanIntersectingQueryWeight w1 = new MtasSpanIntersectingQueryWeight( - q1.createWeight(searcher, needsScores, boost)); + q1.createWeight(searcher, scoreMode, boost)); MtasSpanIntersectingQueryWeight w2 = new MtasSpanIntersectingQueryWeight( - q2.createWeight(searcher, needsScores, boost)); + q2.createWeight(searcher, scoreMode, boost)); // subWeights List<MtasSpanIntersectingQueryWeight> subWeights = new ArrayList<>(); subWeights.add(w1); subWeights.add(w2); // return return new SpanIntersectingWeight(w1, w2, searcher, - needsScores ? getTermContexts(subWeights) : null, boost); + scoreMode.needsScores() ? getTermStates(subWeights) : null, boost); } } @@ -98,13 +99,13 @@ public class MtasSpanIntersectingQuery extends MtasSpanQuery { * @param items the items * @return the term contexts */ - protected Map<Term, TermContext> getTermContexts( + protected Map<Term, TermStates> getTermStates( List<MtasSpanIntersectingQueryWeight> items) { List<SpanWeight> weights = new ArrayList<>(); for (MtasSpanIntersectingQueryWeight item : items) { weights.add(item.spanWeight); } - return getTermContexts(weights); + return getTermStates(weights); } /* @@ -221,7 +222,7 @@ public class MtasSpanIntersectingQuery extends MtasSpanQuery { */ public SpanIntersectingWeight(MtasSpanIntersectingQueryWeight w1, MtasSpanIntersectingQueryWeight w2, IndexSearcher searcher, - Map<Term, TermContext> terms, float boost) throws IOException { + Map<Term, TermStates> terms, float boost) throws IOException { super(MtasSpanIntersectingQuery.this, searcher, terms, boost); this.w1 = w1; this.w2 = w2; @@ -235,9 +236,9 @@ public class MtasSpanIntersectingQuery extends MtasSpanQuery { * Map) */ @Override - public void extractTermContexts(Map<Term, TermContext> contexts) { - w1.spanWeight.extractTermContexts(contexts); - w2.spanWeight.extractTermContexts(contexts); + public void extractTermStates(Map<Term, TermStates> contexts) { + w1.spanWeight.extractTermStates(contexts); + w2.spanWeight.extractTermStates(contexts); } /* diff --git a/src/main/java/mtas/search/spans/MtasSpanMatchAllQuery.java b/src/main/java/mtas/search/spans/MtasSpanMatchAllQuery.java index 8fe927a..9f5bc5e 100644 --- a/src/main/java/mtas/search/spans/MtasSpanMatchAllQuery.java +++ b/src/main/java/mtas/search/spans/MtasSpanMatchAllQuery.java @@ -19,9 +19,11 @@ import org.apache.lucene.index.IndexReaderContext; import org.apache.lucene.index.LeafReader; import org.apache.lucene.index.LeafReaderContext; import org.apache.lucene.index.Term; -import org.apache.lucene.index.TermContext; +import org.apache.lucene.index.TermStates; import org.apache.lucene.index.Terms; import org.apache.lucene.search.IndexSearcher; +import org.apache.lucene.search.LeafSimScorer; +import org.apache.lucene.search.ScoreMode; import org.apache.lucene.search.similarities.Similarity.SimScorer; /** @@ -64,7 +66,7 @@ public class MtasSpanMatchAllQuery extends MtasSpanQuery { */ @Override public MtasSpanWeight createWeight(IndexSearcher searcher, - boolean needsScores, float boost) throws IOException { + ScoreMode scoreMode, float boost) throws IOException { // keep things simple return new SpanAllWeight(searcher, null, boost); } @@ -91,7 +93,7 @@ public class MtasSpanMatchAllQuery extends MtasSpanQuery { * @throws IOException Signals that an I/O exception has occurred. */ public SpanAllWeight(IndexSearcher searcher, - Map<Term, TermContext> termContexts, float boost) throws IOException { + Map<Term, TermStates> termContexts, float boost) throws IOException { super(MtasSpanMatchAllQuery.this, searcher, termContexts, boost); this.searcher = searcher; } @@ -104,12 +106,12 @@ public class MtasSpanMatchAllQuery extends MtasSpanQuery { * Map) */ @Override - public void extractTermContexts(Map<Term, TermContext> contexts) { + public void extractTermStates(Map<Term, TermStates> contexts) { Term term = new Term(field); if (!contexts.containsKey(term)) { IndexReaderContext topContext = searcher.getTopReaderContext(); try { - contexts.put(term, TermContext.build(topContext, term)); + contexts.put(term, TermStates.build(topContext, term, true)); } catch (IOException e) { log.debug(e); // fail @@ -182,8 +184,8 @@ public class MtasSpanMatchAllQuery extends MtasSpanQuery { * index.LeafReaderContext) */ @Override - public SimScorer getSimScorer(LeafReaderContext context) { - return new MtasSimScorer(); + public LeafSimScorer getSimScorer(LeafReaderContext context) throws IOException { + return new LeafSimScorer(new MtasSimScorer(), context.reader(), field, true); } // @Override diff --git a/src/main/java/mtas/search/spans/MtasSpanMatchNoneQuery.java b/src/main/java/mtas/search/spans/MtasSpanMatchNoneQuery.java index 07578ea..1d75a35 100644 --- a/src/main/java/mtas/search/spans/MtasSpanMatchNoneQuery.java +++ b/src/main/java/mtas/search/spans/MtasSpanMatchNoneQuery.java @@ -14,8 +14,10 @@ import mtas.search.spans.util.MtasSpans; import org.apache.lucene.index.LeafReader; import org.apache.lucene.index.LeafReaderContext; import org.apache.lucene.index.Term; -import org.apache.lucene.index.TermContext; +import org.apache.lucene.index.TermStates; import org.apache.lucene.search.IndexSearcher; +import org.apache.lucene.search.LeafSimScorer; +import org.apache.lucene.search.ScoreMode; import org.apache.lucene.search.similarities.Similarity.SimScorer; /** @@ -55,7 +57,7 @@ public class MtasSpanMatchNoneQuery extends MtasSpanQuery { */ @Override public MtasSpanWeight createWeight(IndexSearcher searcher, - boolean needsScores, float boost) throws IOException { + ScoreMode scoreMode, float boost) throws IOException { return new SpanNoneWeight(searcher, null, boost); } @@ -75,7 +77,7 @@ public class MtasSpanMatchNoneQuery extends MtasSpanQuery { * @throws IOException Signals that an I/O exception has occurred. */ public SpanNoneWeight(IndexSearcher searcher, - Map<Term, TermContext> termContexts, float boost) throws IOException { + Map<Term, TermStates> termContexts, float boost) throws IOException { super(MtasSpanMatchNoneQuery.this, searcher, termContexts, boost); } @@ -87,7 +89,7 @@ public class MtasSpanMatchNoneQuery extends MtasSpanQuery { * Map) */ @Override - public void extractTermContexts(Map<Term, TermContext> contexts) { + public void extractTermStates(Map<Term, TermStates> contexts) { // don't do anything } @@ -144,8 +146,8 @@ public class MtasSpanMatchNoneQuery extends MtasSpanQuery { * index.LeafReaderContext) */ @Override - public SimScorer getSimScorer(LeafReaderContext context) { - return new MtasSimScorer(); + public LeafSimScorer getSimScorer(LeafReaderContext context) throws IOException { + return new LeafSimScorer(new MtasSimScorer(), context.reader(), field, true); } // @Override diff --git a/src/main/java/mtas/search/spans/MtasSpanNotQuery.java b/src/main/java/mtas/search/spans/MtasSpanNotQuery.java index 83ece30..5366b99 100644 --- a/src/main/java/mtas/search/spans/MtasSpanNotQuery.java +++ b/src/main/java/mtas/search/spans/MtasSpanNotQuery.java @@ -9,9 +9,10 @@ import java.util.Set; import org.apache.lucene.index.IndexReader; import org.apache.lucene.index.LeafReaderContext; import org.apache.lucene.index.Term; -import org.apache.lucene.index.TermContext; +import org.apache.lucene.index.TermStates; import org.apache.lucene.index.Terms; import org.apache.lucene.search.IndexSearcher; +import org.apache.lucene.search.ScoreMode; import org.apache.lucene.search.spans.SpanNotQuery; import org.apache.lucene.search.spans.SpanWeight; import org.apache.lucene.search.spans.Spans; @@ -79,22 +80,22 @@ public class MtasSpanNotQuery extends MtasSpanQuery { */ @Override public MtasSpanWeight createWeight(IndexSearcher searcher, - boolean needsScores, float boost) throws IOException { + ScoreMode scoreMode, float boost) throws IOException { // return baseQuery.createWeight(searcher, needsScores); if (q1 == null || q2 == null) { return null; } else { MtasSpanNotQueryWeight w1 = new MtasSpanNotQueryWeight( - q1.createWeight(searcher, needsScores, boost)); + q1.createWeight(searcher, scoreMode, boost)); MtasSpanNotQueryWeight w2 = new MtasSpanNotQueryWeight( - q2.createWeight(searcher, needsScores, boost)); + q2.createWeight(searcher, scoreMode, boost)); // subWeights List<MtasSpanNotQueryWeight> subWeights = new ArrayList<>(); subWeights.add(w1); subWeights.add(w2); // return return new SpanNotWeight(w1, w2, searcher, - needsScores ? getTermContexts(subWeights) : null, boost); + scoreMode.needsScores() ? getTermStates(subWeights) : null, boost); } } @@ -104,13 +105,13 @@ public class MtasSpanNotQuery extends MtasSpanQuery { * @param items the items * @return the term contexts */ - protected Map<Term, TermContext> getTermContexts( + protected Map<Term, TermStates> getTermStates( List<MtasSpanNotQueryWeight> items) { List<SpanWeight> weights = new ArrayList<>(); for (MtasSpanNotQueryWeight item : items) { weights.add(item.spanWeight); } - return getTermContexts(weights); + return getTermStates(weights); } /* @@ -215,7 +216,7 @@ public class MtasSpanNotQuery extends MtasSpanQuery { * @throws IOException Signals that an I/O exception has occurred. */ public SpanNotWeight(MtasSpanNotQueryWeight w1, MtasSpanNotQueryWeight w2, - IndexSearcher searcher, Map<Term, TermContext> termContexts, float boost) + IndexSearcher searcher, Map<Term, TermStates> termContexts, float boost) throws IOException { super(MtasSpanNotQuery.this, searcher, termContexts, boost); this.w1 = w1; @@ -230,9 +231,9 @@ public class MtasSpanNotQuery extends MtasSpanQuery { * Map) */ @Override - public void extractTermContexts(Map<Term, TermContext> contexts) { - w1.spanWeight.extractTermContexts(contexts); - w2.spanWeight.extractTermContexts(contexts); + public void extractTermStates(Map<Term, TermStates> contexts) { + w1.spanWeight.extractTermStates(contexts); + w2.spanWeight.extractTermStates(contexts); } /* diff --git a/src/main/java/mtas/search/spans/MtasSpanOrQuery.java b/src/main/java/mtas/search/spans/MtasSpanOrQuery.java index 0f611f1..b64d7e0 100644 --- a/src/main/java/mtas/search/spans/MtasSpanOrQuery.java +++ b/src/main/java/mtas/search/spans/MtasSpanOrQuery.java @@ -7,6 +7,7 @@ import java.util.Objects; import org.apache.lucene.index.IndexReader; import org.apache.lucene.search.IndexSearcher; +import org.apache.lucene.search.ScoreMode; import org.apache.lucene.search.spans.SpanOrQuery; import org.apache.lucene.search.spans.SpanQuery; import org.apache.lucene.search.spans.SpanWeight; @@ -77,9 +78,9 @@ public class MtasSpanOrQuery extends MtasSpanQuery { * IndexSearcher, boolean) */ @Override - public SpanWeight createWeight(IndexSearcher searcher, boolean needsScores, float boost) + public SpanWeight createWeight(IndexSearcher searcher, ScoreMode scoreMode, float boost) throws IOException { - return baseQuery.createWeight(searcher, needsScores, boost); + return baseQuery.createWeight(searcher, scoreMode, boost); } /* diff --git a/src/main/java/mtas/search/spans/MtasSpanPositionQuery.java b/src/main/java/mtas/search/spans/MtasSpanPositionQuery.java index 94e987b..2d93ee5 100644 --- a/src/main/java/mtas/search/spans/MtasSpanPositionQuery.java +++ b/src/main/java/mtas/search/spans/MtasSpanPositionQuery.java @@ -16,9 +16,11 @@ import org.apache.lucene.codecs.FieldsProducer; import org.apache.lucene.index.LeafReader; import org.apache.lucene.index.LeafReaderContext; import org.apache.lucene.index.Term; -import org.apache.lucene.index.TermContext; +import org.apache.lucene.index.TermStates; import org.apache.lucene.index.Terms; import org.apache.lucene.search.IndexSearcher; +import org.apache.lucene.search.LeafSimScorer; +import org.apache.lucene.search.ScoreMode; import org.apache.lucene.search.similarities.Similarity.SimScorer; /** @@ -78,7 +80,7 @@ public class MtasSpanPositionQuery extends MtasSpanQuery { */ @Override public MtasSpanWeight createWeight(IndexSearcher searcher, - boolean needsScores, float boost) throws IOException { + ScoreMode scoreMode, float boost) throws IOException { return new SpanAllWeight(searcher, null, boost); } @@ -101,7 +103,7 @@ public class MtasSpanPositionQuery extends MtasSpanQuery { * @throws IOException Signals that an I/O exception has occurred. */ public SpanAllWeight(IndexSearcher searcher, - Map<Term, TermContext> termContexts, float boost) throws IOException { + Map<Term, TermStates> termContexts, float boost) throws IOException { super(MtasSpanPositionQuery.this, searcher, termContexts, boost); } @@ -113,7 +115,7 @@ public class MtasSpanPositionQuery extends MtasSpanQuery { * Map) */ @Override - public void extractTermContexts(Map<Term, TermContext> contexts) { + public void extractTermStates(Map<Term, TermStates> contexts) { // don't do anything } @@ -182,8 +184,8 @@ public class MtasSpanPositionQuery extends MtasSpanQuery { * index.LeafReaderContext) */ @Override - public SimScorer getSimScorer(LeafReaderContext context) { - return new MtasSimScorer(); + public LeafSimScorer getSimScorer(LeafReaderContext context) throws IOException { + return new LeafSimScorer(new MtasSimScorer(), context.reader(), field, true); } // @Override diff --git a/src/main/java/mtas/search/spans/MtasSpanPrecededByQuery.java b/src/main/java/mtas/search/spans/MtasSpanPrecededByQuery.java index 97fe01b..f6ec334 100644 --- a/src/main/java/mtas/search/spans/MtasSpanPrecededByQuery.java +++ b/src/main/java/mtas/search/spans/MtasSpanPrecededByQuery.java @@ -10,9 +10,10 @@ import java.util.Set; import org.apache.lucene.index.IndexReader; import org.apache.lucene.index.LeafReaderContext; import org.apache.lucene.index.Term; -import org.apache.lucene.index.TermContext; +import org.apache.lucene.index.TermStates; import org.apache.lucene.index.Terms; import org.apache.lucene.search.IndexSearcher; +import org.apache.lucene.search.ScoreMode; import org.apache.lucene.search.spans.SpanWeight; import org.apache.lucene.search.spans.Spans; @@ -75,21 +76,21 @@ public class MtasSpanPrecededByQuery extends MtasSpanQuery { */ @Override public MtasSpanWeight createWeight(IndexSearcher searcher, - boolean needsScores, float boost) throws IOException { + ScoreMode scoreMode, float boost) throws IOException { if (q1 == null || q2 == null) { return null; } else { MtasSpanPrecededByQueryWeight w1 = new MtasSpanPrecededByQueryWeight( - q1.createWeight(searcher, needsScores, boost)); + q1.createWeight(searcher, scoreMode, boost)); MtasSpanPrecededByQueryWeight w2 = new MtasSpanPrecededByQueryWeight( - q2.createWeight(searcher, needsScores, boost)); + q2.createWeight(searcher, scoreMode, boost)); // subWeights List<MtasSpanPrecededByQueryWeight> subWeights = new ArrayList<>(); subWeights.add(w1); subWeights.add(w2); // return return new SpanPrecededByWeight(w1, w2, searcher, - needsScores ? getTermContexts(subWeights) : null, boost); + scoreMode.needsScores() ? getTermStates(subWeights) : null, boost); } } @@ -99,13 +100,13 @@ public class MtasSpanPrecededByQuery extends MtasSpanQuery { * @param items the items * @return the term contexts */ - protected Map<Term, TermContext> getTermContexts( + protected Map<Term, TermStates> getTermStates( List<MtasSpanPrecededByQueryWeight> items) { List<SpanWeight> weights = new ArrayList<>(); for (MtasSpanPrecededByQueryWeight item : items) { weights.add(item.spanWeight); } - return getTermContexts(weights); + return getTermStates(weights); } /* @@ -213,7 +214,7 @@ public class MtasSpanPrecededByQuery extends MtasSpanQuery { */ public SpanPrecededByWeight(MtasSpanPrecededByQueryWeight w1, MtasSpanPrecededByQueryWeight w2, IndexSearcher searcher, - Map<Term, TermContext> terms, float boost) throws IOException { + Map<Term, TermStates> terms, float boost) throws IOException { super(MtasSpanPrecededByQuery.this, searcher, terms, boost); this.w1 = w1; this.w2 = w2; @@ -227,9 +228,9 @@ public class MtasSpanPrecededByQuery extends MtasSpanQuery { * Map) */ @Override - public void extractTermContexts(Map<Term, TermContext> contexts) { - w1.spanWeight.extractTermContexts(contexts); - w2.spanWeight.extractTermContexts(contexts); + public void extractTermStates(Map<Term, TermStates> contexts) { + w1.spanWeight.extractTermStates(contexts); + w2.spanWeight.extractTermStates(contexts); } /* diff --git a/src/main/java/mtas/search/spans/MtasSpanPrefixQuery.java b/src/main/java/mtas/search/spans/MtasSpanPrefixQuery.java index 84e3de1..bc7d2e9 100644 --- a/src/main/java/mtas/search/spans/MtasSpanPrefixQuery.java +++ b/src/main/java/mtas/search/spans/MtasSpanPrefixQuery.java @@ -11,6 +11,7 @@ import org.apache.lucene.index.Term; import org.apache.lucene.search.IndexSearcher; import org.apache.lucene.search.PrefixQuery; import org.apache.lucene.search.Query; +import org.apache.lucene.search.ScoreMode; import org.apache.lucene.search.spans.SpanMultiTermQueryWrapper; import org.apache.lucene.search.spans.SpanOrQuery; import org.apache.lucene.search.spans.SpanQuery; @@ -132,10 +133,10 @@ public class MtasSpanPrefixQuery extends MtasSpanQuery { * search.IndexSearcher, boolean) */ @Override - public SpanWeight createWeight(IndexSearcher searcher, boolean needsScores, float boost) + public SpanWeight createWeight(IndexSearcher searcher, ScoreMode scoreMode, float boost) throws IOException { return ((SpanQuery) searcher.rewrite(query)).createWeight(searcher, - needsScores, boost); + scoreMode, boost); } /* diff --git a/src/main/java/mtas/search/spans/MtasSpanRecurrenceQuery.java b/src/main/java/mtas/search/spans/MtasSpanRecurrenceQuery.java index 1e1cb92..f68c47f 100644 --- a/src/main/java/mtas/search/spans/MtasSpanRecurrenceQuery.java +++ b/src/main/java/mtas/search/spans/MtasSpanRecurrenceQuery.java @@ -8,9 +8,10 @@ import java.util.Set; import org.apache.lucene.index.IndexReader; import org.apache.lucene.index.LeafReaderContext; import org.apache.lucene.index.Term; -import org.apache.lucene.index.TermContext; +import org.apache.lucene.index.TermStates; import org.apache.lucene.index.Terms; import org.apache.lucene.search.IndexSearcher; +import org.apache.lucene.search.ScoreMode; import org.apache.lucene.search.spans.SpanWeight; import org.apache.lucene.search.spans.Spans; @@ -261,15 +262,15 @@ public class MtasSpanRecurrenceQuery extends MtasSpanQuery { */ @Override public MtasSpanWeight createWeight(IndexSearcher searcher, - boolean needsScores, float boost) throws IOException { - SpanWeight subWeight = query.createWeight(searcher, false, boost); + ScoreMode scoreMode, float boost) throws IOException { + SpanWeight subWeight = query.createWeight(searcher, ScoreMode.COMPLETE_NO_SCORES, boost); SpanWeight ignoreWeight = null; if (ignoreQuery != null) { - ignoreWeight = ignoreQuery.createWeight(searcher, false, boost); + ignoreWeight = ignoreQuery.createWeight(searcher, ScoreMode.COMPLETE_NO_SCORES, boost); } return new SpanRecurrenceWeight(subWeight, ignoreWeight, maximumIgnoreLength, searcher, - needsScores ? getTermContexts(subWeight) : null, boost); + scoreMode.needsScores() ? getTermStates(subWeight) : null, boost); } /* @@ -312,7 +313,7 @@ public class MtasSpanRecurrenceQuery extends MtasSpanQuery { */ public SpanRecurrenceWeight(SpanWeight subWeight, SpanWeight ignoreWeight, Integer maximumIgnoreLength, IndexSearcher searcher, - Map<Term, TermContext> terms, float boost) throws IOException { + Map<Term, TermStates> terms, float boost) throws IOException { super(MtasSpanRecurrenceQuery.this, searcher, terms, boost); this.subWeight = subWeight; this.ignoreWeight = ignoreWeight; @@ -327,8 +328,8 @@ public class MtasSpanRecurrenceQuery extends MtasSpanQuery { * Map) */ @Override - public void extractTermContexts(Map<Term, TermContext> contexts) { - subWeight.extractTermContexts(contexts); + public void extractTermStates(Map<Term, TermStates> contexts) { + subWeight.extractTermStates(contexts); } /* diff --git a/src/main/java/mtas/search/spans/MtasSpanRegexpQuery.java b/src/main/java/mtas/search/spans/MtasSpanRegexpQuery.java index 89a6d69..d4542db 100644 --- a/src/main/java/mtas/search/spans/MtasSpanRegexpQuery.java +++ b/src/main/java/mtas/search/spans/MtasSpanRegexpQuery.java @@ -12,6 +12,7 @@ import org.apache.lucene.index.Term; import org.apache.lucene.search.IndexSearcher; import org.apache.lucene.search.Query; import org.apache.lucene.search.RegexpQuery; +import org.apache.lucene.search.ScoreMode; import org.apache.lucene.search.spans.SpanMultiTermQueryWrapper; import org.apache.lucene.search.spans.SpanOrQuery; import org.apache.lucene.search.spans.SpanQuery; @@ -142,10 +143,10 @@ public class MtasSpanRegexpQuery extends MtasSpanQuery { * search.IndexSearcher, boolean) */ @Override - public SpanWeight createWeight(IndexSearcher searcher, boolean needsScores, float boost) + public SpanWeight createWeight(IndexSearcher searcher, ScoreMode scoreMode, float boost) throws IOException { return ((SpanQuery) searcher.rewrite(query)).createWeight(searcher, - needsScores, boost); + scoreMode, boost); } /* diff --git a/src/main/java/mtas/search/spans/MtasSpanSequenceQuery.java b/src/main/java/mtas/search/spans/MtasSpanSequenceQuery.java index 181943d..51d30b7 100644 --- a/src/main/java/mtas/search/spans/MtasSpanSequenceQuery.java +++ b/src/main/java/mtas/search/spans/MtasSpanSequenceQuery.java @@ -11,9 +11,10 @@ import java.util.Set; import org.apache.lucene.index.IndexReader; import org.apache.lucene.index.LeafReaderContext; import org.apache.lucene.index.Term; -import org.apache.lucene.index.TermContext; +import org.apache.lucene.index.TermStates; import org.apache.lucene.index.Terms; import org.apache.lucene.search.IndexSearcher; +import org.apache.lucene.search.ScoreMode; import org.apache.lucene.search.spans.SpanWeight; import org.apache.lucene.search.spans.Spans; @@ -394,18 +395,18 @@ public class MtasSpanSequenceQuery extends MtasSpanQuery { */ @Override public MtasSpanWeight createWeight(IndexSearcher searcher, - boolean needsScores, float boost) throws IOException { + ScoreMode scoreMode, float boost) throws IOException { List<MtasSpanSequenceQueryWeight> subWeights = new ArrayList<>(); SpanWeight ignoreWeight = null; for (MtasSpanSequenceItem item : items) { subWeights.add(new MtasSpanSequenceQueryWeight( - item.getQuery().createWeight(searcher, false, boost), item.isOptional())); + item.getQuery().createWeight(searcher, ScoreMode.COMPLETE_NO_SCORES, boost), item.isOptional())); } if (ignoreQuery != null) { - ignoreWeight = ignoreQuery.createWeight(searcher, false, boost); + ignoreWeight = ignoreQuery.createWeight(searcher, ScoreMode.COMPLETE_NO_SCORES, boost); } return new SpanSequenceWeight(subWeights, ignoreWeight, maximumIgnoreLength, - searcher, needsScores ? getTermContexts(subWeights) : null, boost); + searcher, scoreMode.needsScores() ? getTermStates(subWeights) : null, boost); } /** @@ -414,13 +415,13 @@ public class MtasSpanSequenceQuery extends MtasSpanQuery { * @param items the items * @return the term contexts */ - protected Map<Term, TermContext> getTermContexts( + protected Map<Term, TermStates> getTermStates( List<MtasSpanSequenceQueryWeight> items) { List<SpanWeight> weights = new ArrayList<>(); for (MtasSpanSequenceQueryWeight item : items) { weights.add(item.spanWeight); } - return getTermContexts(weights); + return getTermStates(weights); } /* @@ -465,7 +466,7 @@ public class MtasSpanSequenceQuery extends MtasSpanQuery { */ public SpanSequenceWeight(List<MtasSpanSequenceQueryWeight> subWeights, SpanWeight ignoreWeight, Integer maximumIgnoreLength, - IndexSearcher searcher, Map<Term, TermContext> terms, float boost) + IndexSearcher searcher, Map<Term, TermStates> terms, float boost) throws IOException { super(MtasSpanSequenceQuery.this, searcher, terms, boost); this.subWeights = subWeights; @@ -481,12 +482,12 @@ public class MtasSpanSequenceQuery extends MtasSpanQuery { * Map) */ @Override - public void extractTermContexts(Map<Term, TermContext> contexts) { + public void extractTermStates(Map<Term, TermStates> contexts) { for (MtasSpanSequenceQueryWeight w : subWeights) { - w.spanWeight.extractTermContexts(contexts); + w.spanWeight.extractTermStates(contexts); } if (ignoreWeight != null) { - ignoreWeight.extractTermContexts(contexts); + ignoreWeight.extractTermStates(contexts); } } diff --git a/src/main/java/mtas/search/spans/MtasSpanStartQuery.java b/src/main/java/mtas/search/spans/MtasSpanStartQuery.java index 920fbc6..a36a55a 100644 --- a/src/main/java/mtas/search/spans/MtasSpanStartQuery.java +++ b/src/main/java/mtas/search/spans/MtasSpanStartQuery.java @@ -8,8 +8,9 @@ import java.util.Set; import org.apache.lucene.index.IndexReader; import org.apache.lucene.index.LeafReaderContext; import org.apache.lucene.index.Term; -import org.apache.lucene.index.TermContext; +import org.apache.lucene.index.TermStates; import org.apache.lucene.search.IndexSearcher; +import org.apache.lucene.search.ScoreMode; import org.apache.lucene.search.spans.SpanQuery; import org.apache.lucene.search.spans.SpanWeight; import mtas.search.spans.util.MtasSpanQuery; @@ -91,9 +92,9 @@ public class MtasSpanStartQuery extends MtasSpanQuery { */ @Override public MtasSpanWeight createWeight(IndexSearcher searcher, - boolean needsScores, float boost) throws IOException { + ScoreMode scoreMode, float boost) throws IOException { SpanWeight spanWeight = ((SpanQuery) searcher.rewrite(clause)) - .createWeight(searcher, needsScores, boost); + .createWeight(searcher, scoreMode, boost); return new SpanTermWeight(spanWeight, searcher, boost); } @@ -126,8 +127,8 @@ public class MtasSpanStartQuery extends MtasSpanQuery { * Map) */ @Override - public void extractTermContexts(Map<Term, TermContext> contexts) { - spanWeight.extractTermContexts(contexts); + public void extractTermStates(Map<Term, TermStates> contexts) { + spanWeight.extractTermStates(contexts); } /* diff --git a/src/main/java/mtas/search/spans/MtasSpanTermQuery.java b/src/main/java/mtas/search/spans/MtasSpanTermQuery.java index 5742a38..9151a6b 100644 --- a/src/main/java/mtas/search/spans/MtasSpanTermQuery.java +++ b/src/main/java/mtas/search/spans/MtasSpanTermQuery.java @@ -7,6 +7,7 @@ import mtas.search.spans.util.MtasExtendedSpanTermQuery; import org.apache.lucene.index.IndexReader; import org.apache.lucene.index.Term; import org.apache.lucene.search.IndexSearcher; +import org.apache.lucene.search.ScoreMode; import org.apache.lucene.search.spans.SpanTermQuery; import org.apache.lucene.search.spans.SpanWeight; @@ -56,9 +57,9 @@ public class MtasSpanTermQuery extends MtasSpanQuery { * .search.IndexSearcher, boolean) */ @Override - public SpanWeight createWeight(IndexSearcher searcher, boolean needsScores, float boost) + public SpanWeight createWeight(IndexSearcher searcher, ScoreMode scoreMode, float boost) throws IOException { - return baseQuery.createWeight(searcher, needsScores, boost); + return baseQuery.createWeight(searcher, scoreMode, boost); } /* diff --git a/src/main/java/mtas/search/spans/MtasSpanWildcardQuery.java b/src/main/java/mtas/search/spans/MtasSpanWildcardQuery.java index abc469f..70f9e5c 100644 --- a/src/main/java/mtas/search/spans/MtasSpanWildcardQuery.java +++ b/src/main/java/mtas/search/spans/MtasSpanWildcardQuery.java @@ -11,6 +11,7 @@ import org.apache.lucene.index.IndexReader; import org.apache.lucene.index.Term; import org.apache.lucene.search.IndexSearcher; import org.apache.lucene.search.Query; +import org.apache.lucene.search.ScoreMode; import org.apache.lucene.search.WildcardQuery; import org.apache.lucene.search.spans.SpanMultiTermQueryWrapper; import org.apache.lucene.search.spans.SpanOrQuery; @@ -143,10 +144,10 @@ public class MtasSpanWildcardQuery extends MtasSpanQuery { * search.IndexSearcher, boolean) */ @Override - public SpanWeight createWeight(IndexSearcher searcher, boolean needsScores, float boost) + public SpanWeight createWeight(IndexSearcher searcher, ScoreMode scoreMode, float boost) throws IOException { return ((SpanQuery) searcher.rewrite(query)).createWeight(searcher, - needsScores, boost); + scoreMode, boost); } /* diff --git a/src/main/java/mtas/search/spans/MtasSpanWithinQuery.java b/src/main/java/mtas/search/spans/MtasSpanWithinQuery.java index b0f727c..92381e4 100644 --- a/src/main/java/mtas/search/spans/MtasSpanWithinQuery.java +++ b/src/main/java/mtas/search/spans/MtasSpanWithinQuery.java @@ -7,6 +7,7 @@ import java.util.Objects; import org.apache.lucene.index.IndexReader; import org.apache.lucene.search.IndexSearcher; +import org.apache.lucene.search.ScoreMode; import org.apache.lucene.search.spans.SpanWeight; import org.apache.lucene.search.spans.SpanWithinQuery; import mtas.search.spans.util.MtasMaximumExpandSpanQuery; @@ -289,9 +290,9 @@ public class MtasSpanWithinQuery extends MtasSpanQuery { * search.IndexSearcher, boolean) */ @Override - public SpanWeight createWeight(IndexSearcher searcher, boolean needsScores, float boost) + public SpanWeight createWeight(IndexSearcher searcher, ScoreMode scoreMode, float boost) throws IOException { - return baseQuery.createWeight(searcher, needsScores, boost); + return baseQuery.createWeight(searcher, scoreMode, boost); } /* diff --git a/src/main/java/mtas/search/spans/util/MtasDisabledTwoPhaseIteratorSpanQuery.java b/src/main/java/mtas/search/spans/util/MtasDisabledTwoPhaseIteratorSpanQuery.java index 38c6473..875bd3a 100644 --- a/src/main/java/mtas/search/spans/util/MtasDisabledTwoPhaseIteratorSpanQuery.java +++ b/src/main/java/mtas/search/spans/util/MtasDisabledTwoPhaseIteratorSpanQuery.java @@ -8,8 +8,9 @@ import java.util.Set; import org.apache.lucene.index.IndexReader; import org.apache.lucene.index.LeafReaderContext; import org.apache.lucene.index.Term; -import org.apache.lucene.index.TermContext; +import org.apache.lucene.index.TermStates; import org.apache.lucene.search.IndexSearcher; +import org.apache.lucene.search.ScoreMode; import org.apache.lucene.search.spans.SpanWeight; import mtas.search.spans.MtasSpanMatchNoneQuery; @@ -40,10 +41,10 @@ public class MtasDisabledTwoPhaseIteratorSpanQuery extends MtasSpanQuery { */ @Override public MtasSpanWeight createWeight(IndexSearcher searcher, - boolean needsScores, float boost) throws IOException { - SpanWeight subWeight = subQuery.createWeight(searcher, needsScores, boost); + ScoreMode scoreMode, float boost) throws IOException { + SpanWeight subWeight = subQuery.createWeight(searcher, scoreMode, boost); return new MtasDisabledTwoPhaseIteratorWeight(subWeight, searcher, - needsScores, boost); + scoreMode, boost); } /* @@ -147,9 +148,9 @@ public class MtasDisabledTwoPhaseIteratorSpanQuery extends MtasSpanQuery { * @throws IOException Signals that an I/O exception has occurred. */ public MtasDisabledTwoPhaseIteratorWeight(SpanWeight subWeight, - IndexSearcher searcher, boolean needsScores, float boost) throws IOException { + IndexSearcher searcher, ScoreMode scoreMode, float boost) throws IOException { super(subQuery, searcher, - needsScores ? getTermContexts(subWeight) : null, boost); + scoreMode.needsScores() ? getTermStates(subWeight) : null, boost); this.subWeight = subWeight; } @@ -161,8 +162,8 @@ public class MtasDisabledTwoPhaseIteratorSpanQuery extends MtasSpanQuery { * Map) */ @Override - public void extractTermContexts(Map<Term, TermContext> contexts) { - subWeight.extractTermContexts(contexts); + public void extractTermStates(Map<Term, TermStates> contexts) { + subWeight.extractTermStates(contexts); } /* diff --git a/src/main/java/mtas/search/spans/util/MtasExpandSpanQuery.java b/src/main/java/mtas/search/spans/util/MtasExpandSpanQuery.java index 8570b5c..09d1235 100644 --- a/src/main/java/mtas/search/spans/util/MtasExpandSpanQuery.java +++ b/src/main/java/mtas/search/spans/util/MtasExpandSpanQuery.java @@ -11,9 +11,10 @@ import org.apache.lucene.index.IndexReader; import org.apache.lucene.index.LeafReader; import org.apache.lucene.index.LeafReaderContext; import org.apache.lucene.index.Term; -import org.apache.lucene.index.TermContext; +import org.apache.lucene.index.TermStates; import org.apache.lucene.index.Terms; import org.apache.lucene.search.IndexSearcher; +import org.apache.lucene.search.ScoreMode; import org.apache.lucene.search.spans.SpanWeight; import org.apache.lucene.search.spans.Spans; @@ -80,13 +81,13 @@ public class MtasExpandSpanQuery extends MtasSpanQuery { * IndexSearcher, boolean) */ @Override - public SpanWeight createWeight(IndexSearcher searcher, boolean needsScores, float boost) + public SpanWeight createWeight(IndexSearcher searcher, ScoreMode scoreMode, float boost) throws IOException { - SpanWeight subWeight = query.createWeight(searcher, needsScores, boost); + SpanWeight subWeight = query.createWeight(searcher, scoreMode, boost); if (maximumLeft == 0 && maximumRight == 0) { return subWeight; } else { - return new MtasExpandWeight(subWeight, searcher, needsScores, boost); + return new MtasExpandWeight(subWeight, searcher, scoreMode, boost); } } @@ -210,9 +211,9 @@ public class MtasExpandSpanQuery extends MtasSpanQuery { * @throws IOException Signals that an I/O exception has occurred. */ public MtasExpandWeight(SpanWeight subWeight, IndexSearcher searcher, - boolean needsScores, float boost) throws IOException { + ScoreMode scoreMode, float boost) throws IOException { super(MtasExpandSpanQuery.this, searcher, - needsScores ? getTermContexts(subWeight) : null, boost); + scoreMode.needsScores() ? getTermStates(subWeight) : null, boost); this.subWeight = subWeight; } @@ -224,8 +225,8 @@ public class MtasExpandSpanQuery extends MtasSpanQuery { * Map) */ @Override - public void extractTermContexts(Map<Term, TermContext> contexts) { - subWeight.extractTermContexts(contexts); + public void extractTermStates(Map<Term, TermStates> contexts) { + subWeight.extractTermStates(contexts); } /* diff --git a/src/main/java/mtas/search/spans/util/MtasExtendedSpanTermQuery.java b/src/main/java/mtas/search/spans/util/MtasExtendedSpanTermQuery.java index 51e98f9..d767b83 100644 --- a/src/main/java/mtas/search/spans/util/MtasExtendedSpanTermQuery.java +++ b/src/main/java/mtas/search/spans/util/MtasExtendedSpanTermQuery.java @@ -14,11 +14,12 @@ import org.apache.lucene.index.LeafReader; import org.apache.lucene.index.LeafReaderContext; import org.apache.lucene.index.PostingsEnum; import org.apache.lucene.index.Term; -import org.apache.lucene.index.TermContext; import org.apache.lucene.index.TermState; +import org.apache.lucene.index.TermStates; import org.apache.lucene.index.Terms; import org.apache.lucene.index.TermsEnum; import org.apache.lucene.search.IndexSearcher; +import org.apache.lucene.search.ScoreMode; import org.apache.lucene.search.spans.FilterSpans; import org.apache.lucene.search.spans.SpanTermQuery; import org.apache.lucene.search.spans.SpanWeight; @@ -90,17 +91,17 @@ public class MtasExtendedSpanTermQuery extends SpanTermQuery { * .search.IndexSearcher, boolean) */ @Override - public SpanWeight createWeight(IndexSearcher searcher, boolean needsScores, float boost) + public SpanWeight createWeight(IndexSearcher searcher, ScoreMode scoreMode, float boost) throws IOException { - final TermContext context; + final TermStates context; final IndexReaderContext topContext = searcher.getTopReaderContext(); - if (termContext == null) { - context = TermContext.build(topContext, localTerm); + if (termStates == null) { + context = TermStates.build(topContext, localTerm, true); } else { - context = termContext; + context = termStates; } return new SpanTermWeight(context, searcher, - needsScores ? Collections.singletonMap(localTerm, context) : null, boost); + scoreMode.needsScores() ? Collections.singletonMap(localTerm, context) : null, boost); } /** @@ -111,8 +112,8 @@ public class MtasExtendedSpanTermQuery extends SpanTermQuery { /** The Constant METHOD_GET_DELEGATE. */ private static final String METHOD_GET_DELEGATE = "getDelegate"; - /** The term context. */ - final TermContext termContext; + /** The term states. */ + final TermStates termStates; /** * Instantiates a new span term weight. @@ -122,11 +123,11 @@ public class MtasExtendedSpanTermQuery extends SpanTermQuery { * @param terms the terms * @throws IOException Signals that an I/O exception has occurred. */ - public SpanTermWeight(TermContext termContext, IndexSearcher searcher, - Map<Term, TermContext> terms, float boost) throws IOException { + public SpanTermWeight(TermStates termStates, IndexSearcher searcher, + Map<Term, TermStates> terms, float boost) throws IOException { super(MtasExtendedSpanTermQuery.this, searcher, terms, boost); - this.termContext = termContext; - assert termContext != null : "TermContext must not be null"; + this.termStates = termStates; + assert termStates != null : "TermStates must not be null"; } /* @@ -147,8 +148,8 @@ public class MtasExtendedSpanTermQuery extends SpanTermQuery { * .Map) */ @Override - public void extractTermContexts(Map<Term, TermContext> contexts) { - contexts.put(localTerm, termContext); + public void extractTermStates(Map<Term, TermStates> contexts) { + contexts.put(localTerm, termStates); } /* @@ -162,7 +163,7 @@ public class MtasExtendedSpanTermQuery extends SpanTermQuery { @Override public Spans getSpans(final LeafReaderContext context, Postings requiredPostings) throws IOException { - final TermState state = termContext.get(context.ord); + final TermState state = termStates.get(context); if (state == null) { // term is not present in that reader assert context.reader().docFreq( localTerm) == 0 : "no termstate found but term exists in reader term=" diff --git a/src/main/java/mtas/search/spans/util/MtasMaximumExpandSpanQuery.java b/src/main/java/mtas/search/spans/util/MtasMaximumExpandSpanQuery.java index e2b197b..b9443e8 100644 --- a/src/main/java/mtas/search/spans/util/MtasMaximumExpandSpanQuery.java +++ b/src/main/java/mtas/search/spans/util/MtasMaximumExpandSpanQuery.java @@ -11,9 +11,10 @@ import org.apache.lucene.index.IndexReader; import org.apache.lucene.index.LeafReader; import org.apache.lucene.index.LeafReaderContext; import org.apache.lucene.index.Term; -import org.apache.lucene.index.TermContext; +import org.apache.lucene.index.TermStates; import org.apache.lucene.index.Terms; import org.apache.lucene.search.IndexSearcher; +import org.apache.lucene.search.ScoreMode; import org.apache.lucene.search.spans.SpanWeight; import org.apache.lucene.search.spans.Spans; @@ -80,13 +81,13 @@ public class MtasMaximumExpandSpanQuery extends MtasSpanQuery { * IndexSearcher, boolean) */ @Override - public SpanWeight createWeight(IndexSearcher searcher, boolean needsScores, float boost) + public SpanWeight createWeight(IndexSearcher searcher, ScoreMode scoreMode, float boost) throws IOException { - SpanWeight subWeight = query.createWeight(searcher, needsScores, boost); + SpanWeight subWeight = query.createWeight(searcher, scoreMode, boost); if (maximumLeft == 0 && maximumRight == 0) { return subWeight; } else { - return new MtasMaximumExpandWeight(subWeight, searcher, needsScores, boost); + return new MtasMaximumExpandWeight(subWeight, searcher, scoreMode, boost); } } @@ -205,9 +206,9 @@ public class MtasMaximumExpandSpanQuery extends MtasSpanQuery { * @throws IOException Signals that an I/O exception has occurred. */ public MtasMaximumExpandWeight(SpanWeight subWeight, IndexSearcher searcher, - boolean needsScores, float boost) throws IOException { + ScoreMode scoreMode, float boost) throws IOException { super(MtasMaximumExpandSpanQuery.this, searcher, - needsScores ? getTermContexts(subWeight) : null, boost); + scoreMode.needsScores() ? getTermStates(subWeight) : null, boost); this.subWeight = subWeight; } @@ -219,8 +220,8 @@ public class MtasMaximumExpandSpanQuery extends MtasSpanQuery { * Map) */ @Override - public void extractTermContexts(Map<Term, TermContext> contexts) { - subWeight.extractTermContexts(contexts); + public void extractTermStates(Map<Term, TermStates> contexts) { + subWeight.extractTermStates(contexts); } /* diff --git a/src/main/java/mtas/search/spans/util/MtasSpanUniquePositionQuery.java b/src/main/java/mtas/search/spans/util/MtasSpanUniquePositionQuery.java index 5d92e27..657d514 100644 --- a/src/main/java/mtas/search/spans/util/MtasSpanUniquePositionQuery.java +++ b/src/main/java/mtas/search/spans/util/MtasSpanUniquePositionQuery.java @@ -8,8 +8,9 @@ import java.util.Set; import org.apache.lucene.index.IndexReader; import org.apache.lucene.index.LeafReaderContext; import org.apache.lucene.index.Term; -import org.apache.lucene.index.TermContext; +import org.apache.lucene.index.TermStates; import org.apache.lucene.search.IndexSearcher; +import org.apache.lucene.search.ScoreMode; import org.apache.lucene.search.spans.SpanWeight; import org.apache.lucene.search.spans.Spans; @@ -120,10 +121,10 @@ public class MtasSpanUniquePositionQuery extends MtasSpanQuery { */ @Override public MtasSpanWeight createWeight(IndexSearcher searcher, - boolean needsScores, float boost) throws IOException { - SpanWeight subWeight = clause.createWeight(searcher, false, boost); + ScoreMode scoreMode, float boost) throws IOException { + SpanWeight subWeight = clause.createWeight(searcher, ScoreMode.COMPLETE_NO_SCORES, boost); return new SpanUniquePositionWeight(subWeight, searcher, - needsScores ? getTermContexts(subWeight) : null, boost); + scoreMode.needsScores() ? getTermStates(subWeight) : null, boost); } /* @@ -159,7 +160,7 @@ public class MtasSpanUniquePositionQuery extends MtasSpanQuery { * @throws IOException Signals that an I/O exception has occurred. */ public SpanUniquePositionWeight(SpanWeight subWeight, - IndexSearcher searcher, Map<Term, TermContext> terms, float boost) + IndexSearcher searcher, Map<Term, TermStates> terms, float boost) throws IOException { super(MtasSpanUniquePositionQuery.this, searcher, terms, boost); this.subWeight = subWeight; @@ -173,8 +174,8 @@ public class MtasSpanUniquePositionQuery extends MtasSpanQuery { * Map) */ @Override - public void extractTermContexts(Map<Term, TermContext> contexts) { - subWeight.extractTermContexts(contexts); + public void extractTermStates(Map<Term, TermStates> contexts) { + subWeight.extractTermStates(contexts); } /* diff --git a/src/main/java/mtas/search/spans/util/MtasSpanWeight.java b/src/main/java/mtas/search/spans/util/MtasSpanWeight.java index 63c8a82..87c42d1 100644 --- a/src/main/java/mtas/search/spans/util/MtasSpanWeight.java +++ b/src/main/java/mtas/search/spans/util/MtasSpanWeight.java @@ -5,7 +5,7 @@ import java.util.Map; import org.apache.lucene.index.LeafReaderContext; import org.apache.lucene.index.Term; -import org.apache.lucene.index.TermContext; +import org.apache.lucene.index.TermStates; import org.apache.lucene.search.IndexSearcher; import org.apache.lucene.search.spans.SpanQuery; import org.apache.lucene.search.spans.SpanWeight; @@ -28,7 +28,7 @@ public abstract class MtasSpanWeight extends SpanWeight { * Signals that an I/O exception has occurred. */ public MtasSpanWeight(SpanQuery query, IndexSearcher searcher, - Map<Term, TermContext> termContexts, float boost) throws IOException { + Map<Term, TermStates> termContexts, float boost) throws IOException { super(query, searcher, termContexts, boost); } diff --git a/src/test/java/mtas/search/MtasSearchTestConsistency.java b/src/test/java/mtas/search/MtasSearchTestConsistency.java index efc5703..44992d0 100644 --- a/src/test/java/mtas/search/MtasSearchTestConsistency.java +++ b/src/test/java/mtas/search/MtasSearchTestConsistency.java @@ -41,6 +41,7 @@ import org.apache.lucene.index.SegmentReader; import org.apache.lucene.index.Term; import org.apache.lucene.index.Terms; import org.apache.lucene.search.IndexSearcher; +import org.apache.lucene.search.ScoreMode; import org.apache.lucene.search.spans.SpanWeight; import org.apache.lucene.search.spans.Spans; import org.apache.lucene.store.Directory; @@ -1396,7 +1397,7 @@ public class MtasSearchTestConsistency { .listIterator(); IndexSearcher searcher = new IndexSearcher(indexReader); final float boost = 0; - SpanWeight spanweight = q.rewrite(indexReader).createWeight(searcher, false, + SpanWeight spanweight = q.rewrite(indexReader).createWeight(searcher, ScoreMode.COMPLETE_NO_SCORES, boost); while (iterator.hasNext()) { diff --git a/src/test/java/mtas/solr/MtasSolrTestDistributedSearchConsistency.java b/src/test/java/mtas/solr/MtasSolrTestDistributedSearchConsistency.java index c46ac2a..3afc2ec 100644 --- a/src/test/java/mtas/solr/MtasSolrTestDistributedSearchConsistency.java +++ b/src/test/java/mtas/solr/MtasSolrTestDistributedSearchConsistency.java @@ -960,7 +960,8 @@ public class MtasSolrTestDistributedSearchConsistency { Path dataPath = Paths.get("src" + File.separator + "test" + File.separator + "resources" + File.separator + "data"); String solrxml = MiniSolrCloudCluster.DEFAULT_CLOUD_SOLR_XML; - JettyConfig jettyConfig = JettyConfig.builder().setContext("/solr").build(); + JettyConfig jettyConfig = JettyConfig.builder().setContext("/solr").useOnlyHttp1(true).build(); + //JettyConfig jettyConfig = JettyConfig.builder().setContext("/solr").useOnlyHttp1(false).build(); File cloudBase = Files.createTempDir(); cloudBaseDir = cloudBase.toPath(); // create subdirectories -- GitLab