blob: 2eadc2b5e1f81d7a7a64d5e7a1eab127aa0aad86 [file] [log] [blame]
diff --git a/lucene/core/src/java/org/apache/lucene/document/FeatureField.java b/lucene/core/src/java/org/apache/lucene/document/FeatureField.java
index 1b8a4e5..6ff99be 100644
--- a/lucene/core/src/java/org/apache/lucene/document/FeatureField.java
+++ b/lucene/core/src/java/org/apache/lucene/document/FeatureField.java
@@ -208,7 +208,7 @@ public final class FeatureField extends Field {
}
static abstract class FeatureFunction {
- abstract SimScorer scorer(String field, float w);
+ abstract SimScorer scorer(float w);
abstract Explanation explain(String field, String feature, float w, int freq);
}
@@ -240,8 +240,8 @@ public final class FeatureField extends Field {
}
@Override
- SimScorer scorer(String field, float weight) {
- return new SimScorer(field) {
+ SimScorer scorer(float weight) {
+ return new SimScorer() {
@Override
public float score(float freq, long norm) {
return (float) (weight * Math.log(scalingFactor + decodeFeatureValue(freq)));
@@ -252,7 +252,7 @@ public final class FeatureField extends Field {
@Override
Explanation explain(String field, String feature, float w, int freq) {
float featureValue = decodeFeatureValue(freq);
- float score = scorer(field, w).score(freq, 1L);
+ float score = scorer(w).score(freq, 1L);
return Explanation.match(score,
"Log function on the " + field + " field for the " + feature + " feature, computed as w * log(a + S) from:",
Explanation.match(w, "w, weight of this function"),
@@ -289,8 +289,8 @@ public final class FeatureField extends Field {
}
@Override
- SimScorer scorer(String field, float weight) {
- return new SimScorer(field) {
+ SimScorer scorer(float weight) {
+ return new SimScorer() {
@Override
public float score(float freq, long norm) {
float f = decodeFeatureValue(freq);
@@ -305,7 +305,7 @@ public final class FeatureField extends Field {
@Override
Explanation explain(String field, String feature, float weight, int freq) {
float featureValue = decodeFeatureValue(freq);
- float score = scorer(field, weight).score(freq, 1L);
+ float score = scorer(weight).score(freq, 1L);
return Explanation.match(score,
"Saturation function on the " + field + " field for the " + feature + " feature, computed as w * S / (S + k) from:",
Explanation.match(weight, "w, weight of this function"),
@@ -348,8 +348,8 @@ public final class FeatureField extends Field {
}
@Override
- SimScorer scorer(String field, float weight) {
- return new SimScorer(field) {
+ SimScorer scorer(float weight) {
+ return new SimScorer() {
@Override
public float score(float freq, long norm) {
float f = decodeFeatureValue(freq);
@@ -364,7 +364,7 @@ public final class FeatureField extends Field {
@Override
Explanation explain(String field, String feature, float weight, int freq) {
float featureValue = decodeFeatureValue(freq);
- float score = scorer(field, weight).score(freq, 1L);
+ float score = scorer(weight).score(freq, 1L);
return Explanation.match(score,
"Sigmoid function on the " + field + " field for the " + feature + " feature, computed as w * S^a / (S^a + k^a) from:",
Explanation.match(weight, "w, weight of this function"),
diff --git a/lucene/core/src/java/org/apache/lucene/document/FeatureQuery.java b/lucene/core/src/java/org/apache/lucene/document/FeatureQuery.java
index 2b38712..9b52a33 100644
--- a/lucene/core/src/java/org/apache/lucene/document/FeatureQuery.java
+++ b/lucene/core/src/java/org/apache/lucene/document/FeatureQuery.java
@@ -114,7 +114,7 @@ final class FeatureQuery extends Query {
return null;
}
- SimScorer scorer = function.scorer(fieldName, boost);
+ SimScorer scorer = function.scorer(boost);
ImpactsEnum impacts = termsEnum.impacts(PostingsEnum.FREQS);
MaxScoreCache maxScoreCache = new MaxScoreCache(impacts, scorer);
diff --git a/lucene/core/src/java/org/apache/lucene/search/LeafSimScorer.java b/lucene/core/src/java/org/apache/lucene/search/LeafSimScorer.java
index f3dc5ea..b65d538 100644
--- a/lucene/core/src/java/org/apache/lucene/search/LeafSimScorer.java
+++ b/lucene/core/src/java/org/apache/lucene/search/LeafSimScorer.java
@@ -17,6 +17,7 @@
package org.apache.lucene.search;
import java.io.IOException;
+import java.util.Objects;
import org.apache.lucene.index.LeafReader;
import org.apache.lucene.index.NumericDocValues;
@@ -29,15 +30,13 @@ public final class LeafSimScorer {
private final SimScorer scorer;
private final NumericDocValues norms;
- private final float maxScore;
/**
* Sole constructor: Score documents of {@code reader} with {@code scorer}.
*/
- public LeafSimScorer(SimScorer scorer, LeafReader reader, boolean needsScores, float maxFreq) throws IOException {
- this.scorer = scorer;
- norms = needsScores ? reader.getNormValues(scorer.getField()) : null;
- maxScore = needsScores ? scorer.score(maxFreq, 1) : Float.MAX_VALUE;
+ public LeafSimScorer(SimScorer scorer, LeafReader reader, String field, boolean needsScores) throws IOException {
+ this.scorer = Objects.requireNonNull(scorer);
+ norms = needsScores ? reader.getNormValues(field) : null;
}
/** Return the wrapped {@link SimScorer}. */
@@ -69,10 +68,4 @@ public final class LeafSimScorer {
return scorer.explain(freqExpl, getNormValue(doc));
}
- /**
- * Return an upper bound of the score.
- */
- public float maxScore() {
- return maxScore;
- }
}
diff --git a/lucene/core/src/java/org/apache/lucene/search/PhraseScorer.java b/lucene/core/src/java/org/apache/lucene/search/PhraseScorer.java
index 4e6dab7..807a9dd 100644
--- a/lucene/core/src/java/org/apache/lucene/search/PhraseScorer.java
+++ b/lucene/core/src/java/org/apache/lucene/search/PhraseScorer.java
@@ -89,7 +89,8 @@ class PhraseScorer extends Scorer {
@Override
public float getMaxScore(int upTo) throws IOException {
- return simScorer.maxScore();
+ // TODO: merge impacts of all clauses to get better score upper bounds
+ return simScorer.getSimScorer().score(Integer.MAX_VALUE, 1L);
}
@Override
diff --git a/lucene/core/src/java/org/apache/lucene/search/PhraseWeight.java b/lucene/core/src/java/org/apache/lucene/search/PhraseWeight.java
index 494003f..90fa537 100644
--- a/lucene/core/src/java/org/apache/lucene/search/PhraseWeight.java
+++ b/lucene/core/src/java/org/apache/lucene/search/PhraseWeight.java
@@ -21,6 +21,7 @@ import java.io.IOException;
import org.apache.lucene.index.LeafReaderContext;
import org.apache.lucene.search.similarities.Similarity;
+import org.apache.lucene.search.similarities.Similarity.SimScorer;
abstract class PhraseWeight extends Weight {
@@ -34,7 +35,16 @@ abstract class PhraseWeight extends Weight {
this.scoreMode = scoreMode;
this.field = field;
this.similarity = searcher.getSimilarity();
- this.stats = getStats(searcher);
+ SimScorer stats = getStats(searcher);
+ if (stats == null) { // Means no terms or scores are not needed
+ stats = new SimScorer() {
+ @Override
+ public float score(float freq, long norm) {
+ return 1;
+ }
+ };
+ }
+ this.stats = stats;
}
protected abstract Similarity.SimScorer getStats(IndexSearcher searcher) throws IOException;
@@ -46,7 +56,7 @@ abstract class PhraseWeight extends Weight {
PhraseMatcher matcher = getPhraseMatcher(context, false);
if (matcher == null)
return null;
- LeafSimScorer simScorer = new LeafSimScorer(stats, context.reader(), scoreMode.needsScores(), Integer.MAX_VALUE);
+ LeafSimScorer simScorer = new LeafSimScorer(stats, context.reader(), field, scoreMode.needsScores());
return new PhraseScorer(this, matcher, scoreMode, simScorer);
}
@@ -64,7 +74,7 @@ abstract class PhraseWeight extends Weight {
while (matcher.nextMatch()) {
freq += matcher.sloppyWeight();
}
- LeafSimScorer docScorer = new LeafSimScorer(stats, context.reader(), scoreMode.needsScores(), Float.MAX_VALUE);
+ LeafSimScorer docScorer = new LeafSimScorer(stats, context.reader(), field, scoreMode.needsScores());
Explanation freqExplanation = Explanation.match(freq, "phraseFreq=" + freq);
Explanation scoreExplanation = docScorer.explain(doc, freqExplanation);
return Explanation.match(
diff --git a/lucene/core/src/java/org/apache/lucene/search/SynonymQuery.java b/lucene/core/src/java/org/apache/lucene/search/SynonymQuery.java
index a364c9a..84ceab0 100644
--- a/lucene/core/src/java/org/apache/lucene/search/SynonymQuery.java
+++ b/lucene/core/src/java/org/apache/lucene/search/SynonymQuery.java
@@ -25,8 +25,6 @@ import java.util.List;
import java.util.Objects;
import java.util.Set;
-import org.apache.lucene.index.FieldInfo;
-import org.apache.lucene.index.IndexOptions;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.LeafReaderContext;
import org.apache.lucene.index.Term;
@@ -184,7 +182,7 @@ public final class SynonymQuery extends Query {
assert scorer instanceof TermScorer;
freq = ((TermScorer)scorer).freq();
}
- LeafSimScorer docScorer = new LeafSimScorer(simWeight, context.reader(), true, Float.MAX_VALUE);
+ LeafSimScorer docScorer = new LeafSimScorer(simWeight, context.reader(), terms[0].field(), true);
Explanation freqExplanation = Explanation.match(freq, "termFreq=" + freq);
Explanation scoreExplanation = docScorer.explain(doc, freqExplanation);
return Explanation.match(
@@ -199,26 +197,14 @@ public final class SynonymQuery extends Query {
@Override
public Scorer scorer(LeafReaderContext context) throws IOException {
- IndexOptions indexOptions = IndexOptions.NONE;
- if (terms.length > 0) {
- FieldInfo info = context.reader()
- .getFieldInfos()
- .fieldInfo(terms[0].field());
- if (info != null) {
- indexOptions = info.getIndexOptions();
- }
- }
// we use termscorers + disjunction as an impl detail
List<Scorer> subScorers = new ArrayList<>();
- long totalMaxFreq = 0;
for (int i = 0; i < terms.length; i++) {
TermState state = termStates[i].get(context);
if (state != null) {
TermsEnum termsEnum = context.reader().terms(terms[i].field()).iterator();
termsEnum.seekExact(terms[i].bytes(), state);
- long termMaxFreq = getMaxFreq(indexOptions, termsEnum.totalTermFreq(), termsEnum.docFreq());
- totalMaxFreq += termMaxFreq;
- LeafSimScorer simScorer = new LeafSimScorer(simWeight, context.reader(), true, termMaxFreq);
+ LeafSimScorer simScorer = new LeafSimScorer(simWeight, context.reader(), terms[0].field(), true);
subScorers.add(new TermScorer(this, termsEnum, ScoreMode.COMPLETE, simScorer));
}
}
@@ -228,7 +214,7 @@ public final class SynonymQuery extends Query {
// we must optimize this case (term not in segment), disjunctionscorer requires >= 2 subs
return subScorers.get(0);
} else {
- LeafSimScorer simScorer = new LeafSimScorer(simWeight, context.reader(), true, totalMaxFreq);
+ LeafSimScorer simScorer = new LeafSimScorer(simWeight, context.reader(), terms[0].field(), true);
return new SynonymScorer(simScorer, this, subScorers);
}
}
@@ -240,17 +226,6 @@ public final class SynonymQuery extends Query {
}
- private long getMaxFreq(IndexOptions indexOptions, long ttf, long df) {
- // TODO: store the max term freq?
- if (indexOptions.compareTo(IndexOptions.DOCS) <= 0) {
- // omitTFAP field, tf values are implicitly 1.
- return 1;
- } else {
- assert ttf >= 0;
- return Math.min(Integer.MAX_VALUE, ttf - df + 1);
- }
- }
-
static class SynonymScorer extends DisjunctionScorer {
private final LeafSimScorer similarity;
@@ -266,7 +241,8 @@ public final class SynonymQuery extends Query {
@Override
public float getMaxScore(int upTo) throws IOException {
- return similarity.maxScore();
+ // TODO: merge impacts to get better score upper bounds
+ return similarity.getSimScorer().score(Float.MAX_VALUE, 1L);
}
/** combines TF of all subs. */
diff --git a/lucene/core/src/java/org/apache/lucene/search/TermQuery.java b/lucene/core/src/java/org/apache/lucene/search/TermQuery.java
index 27b42ad..b7b25ca 100644
--- a/lucene/core/src/java/org/apache/lucene/search/TermQuery.java
+++ b/lucene/core/src/java/org/apache/lucene/search/TermQuery.java
@@ -21,7 +21,6 @@ import java.io.IOException;
import java.util.Objects;
import java.util.Set;
-import org.apache.lucene.index.IndexOptions;
import org.apache.lucene.index.IndexReaderContext;
import org.apache.lucene.index.LeafReader;
import org.apache.lucene.index.LeafReaderContext;
@@ -111,26 +110,10 @@ public class TermQuery extends Query {
if (termsEnum == null) {
return null;
}
- IndexOptions indexOptions = context.reader()
- .getFieldInfos()
- .fieldInfo(getTerm().field())
- .getIndexOptions();
- float maxFreq = getMaxFreq(indexOptions, termsEnum.totalTermFreq(), termsEnum.docFreq());
- LeafSimScorer scorer = new LeafSimScorer(simScorer, context.reader(), scoreMode.needsScores(), maxFreq);
+ LeafSimScorer scorer = new LeafSimScorer(simScorer, context.reader(), term.field(), scoreMode.needsScores());
return new TermScorer(this, termsEnum, scoreMode, scorer);
}
- private long getMaxFreq(IndexOptions indexOptions, long ttf, long df) {
- // TODO: store the max term freq?
- if (indexOptions.compareTo(IndexOptions.DOCS) <= 0) {
- // omitTFAP field, tf values are implicitly 1.
- return 1;
- } else {
- assert ttf >= 0;
- return Math.min(Integer.MAX_VALUE, ttf - df + 1);
- }
- }
-
@Override
public boolean isCacheable(LeafReaderContext ctx) {
return true;
@@ -168,7 +151,7 @@ public class TermQuery extends Query {
int newDoc = scorer.iterator().advance(doc);
if (newDoc == doc) {
float freq = scorer.freq();
- LeafSimScorer docScorer = new LeafSimScorer(simScorer, context.reader(), true, Integer.MAX_VALUE);
+ LeafSimScorer docScorer = new LeafSimScorer(simScorer, context.reader(), term.field(), true);
Explanation freqExplanation = Explanation.match(freq, "freq, occurrences of term within document");
Explanation scoreExplanation = docScorer.explain(doc, freqExplanation);
return Explanation.match(
diff --git a/lucene/core/src/java/org/apache/lucene/search/similarities/BM25Similarity.java b/lucene/core/src/java/org/apache/lucene/search/similarities/BM25Similarity.java
index 09e2e07..e1d4242 100644
--- a/lucene/core/src/java/org/apache/lucene/search/similarities/BM25Similarity.java
+++ b/lucene/core/src/java/org/apache/lucene/search/similarities/BM25Similarity.java
@@ -189,7 +189,7 @@ public class BM25Similarity extends Similarity {
for (int i = 0; i < cache.length; i++) {
cache[i] = k1 * ((1 - b) + b * LENGTH_TABLE[i] / avgdl);
}
- return new BM25Scorer(collectionStats.field(), boost, k1, b, idf, avgdl, cache);
+ return new BM25Scorer(boost, k1, b, idf, avgdl, cache);
}
/** Collection statistics for the BM25 model. */
@@ -209,8 +209,7 @@ public class BM25Similarity extends Similarity {
/** weight (idf * boost) */
private final float weight;
- BM25Scorer(String field, float boost, float k1, float b, Explanation idf, float avgdl, float[] cache) {
- super(field);
+ BM25Scorer(float boost, float k1, float b, Explanation idf, float avgdl, float[] cache) {
this.boost = boost;
this.idf = idf;
this.avgdl = avgdl;
diff --git a/lucene/core/src/java/org/apache/lucene/search/similarities/BooleanSimilarity.java b/lucene/core/src/java/org/apache/lucene/search/similarities/BooleanSimilarity.java
index 3c9206d..b076885 100644
--- a/lucene/core/src/java/org/apache/lucene/search/similarities/BooleanSimilarity.java
+++ b/lucene/core/src/java/org/apache/lucene/search/similarities/BooleanSimilarity.java
@@ -45,14 +45,13 @@ public class BooleanSimilarity extends Similarity {
@Override
public SimScorer scorer(float boost, CollectionStatistics collectionStats, TermStatistics... termStats) {
- return new BooleanWeight(collectionStats.field(), boost);
+ return new BooleanWeight(boost);
}
private static class BooleanWeight extends SimScorer {
final float boost;
- BooleanWeight(String field, float boost) {
- super(field);
+ BooleanWeight(float boost) {
this.boost = boost;
}
diff --git a/lucene/core/src/java/org/apache/lucene/search/similarities/MultiSimilarity.java b/lucene/core/src/java/org/apache/lucene/search/similarities/MultiSimilarity.java
index e558c6e..38ce79a 100644
--- a/lucene/core/src/java/org/apache/lucene/search/similarities/MultiSimilarity.java
+++ b/lucene/core/src/java/org/apache/lucene/search/similarities/MultiSimilarity.java
@@ -52,14 +52,13 @@ public class MultiSimilarity extends Similarity {
for (int i = 0; i < subScorers.length; i++) {
subScorers[i] = sims[i].scorer(boost, collectionStats, termStats);
}
- return new MultiSimScorer(collectionStats.field(), subScorers);
+ return new MultiSimScorer(subScorers);
}
static class MultiSimScorer extends SimScorer {
private final SimScorer subScorers[];
- MultiSimScorer(String field, SimScorer subScorers[]) {
- super(field);
+ MultiSimScorer(SimScorer subScorers[]) {
this.subScorers = subScorers;
}
diff --git a/lucene/core/src/java/org/apache/lucene/search/similarities/Similarity.java b/lucene/core/src/java/org/apache/lucene/search/similarities/Similarity.java
index f296c02..daf7c69 100644
--- a/lucene/core/src/java/org/apache/lucene/search/similarities/Similarity.java
+++ b/lucene/core/src/java/org/apache/lucene/search/similarities/Similarity.java
@@ -18,7 +18,6 @@ package org.apache.lucene.search.similarities;
import java.util.Collections;
-import java.util.Objects;
import org.apache.lucene.document.NumericDocValuesField;
import org.apache.lucene.index.FieldInvertState;
@@ -141,20 +140,11 @@ public abstract class Similarity {
*/
public static abstract class SimScorer {
- private final String field;
-
/**
* Sole constructor. (For invocation by subclass
* constructors.)
*/
- public SimScorer(String field) {
- this.field = Objects.requireNonNull(field);
- }
-
- /** Return the field that this {@link SimScorer} operates on. */
- public final String getField() {
- return field;
- }
+ protected SimScorer() {}
/**
* Score a single document. {@code freq} is the document-term sloppy
diff --git a/lucene/core/src/java/org/apache/lucene/search/similarities/SimilarityBase.java b/lucene/core/src/java/org/apache/lucene/search/similarities/SimilarityBase.java
index 1b0ced5..87cb2ae 100644
--- a/lucene/core/src/java/org/apache/lucene/search/similarities/SimilarityBase.java
+++ b/lucene/core/src/java/org/apache/lucene/search/similarities/SimilarityBase.java
@@ -90,7 +90,7 @@ public abstract class SimilarityBase extends Similarity {
if (weights.length == 1) {
return weights[0];
} else {
- return new MultiSimilarity.MultiSimScorer(collectionStats.field(), weights);
+ return new MultiSimilarity.MultiSimScorer(weights);
}
}
@@ -216,7 +216,6 @@ public abstract class SimilarityBase extends Similarity {
final BasicStats stats;
BasicSimScorer(BasicStats stats) {
- super(stats.field);
this.stats = stats;
}
diff --git a/lucene/core/src/java/org/apache/lucene/search/similarities/TFIDFSimilarity.java b/lucene/core/src/java/org/apache/lucene/search/similarities/TFIDFSimilarity.java
index 3ea567b..b96ef65 100644
--- a/lucene/core/src/java/org/apache/lucene/search/similarities/TFIDFSimilarity.java
+++ b/lucene/core/src/java/org/apache/lucene/search/similarities/TFIDFSimilarity.java
@@ -523,7 +523,7 @@ public abstract class TFIDFSimilarity extends Similarity {
normTable[i] = norm;
}
normTable[0] = 1f / normTable[255];
- return new TFIDFScorer(collectionStats.field(), boost, idf, normTable);
+ return new TFIDFScorer(boost, idf, normTable);
}
@@ -536,8 +536,7 @@ public abstract class TFIDFSimilarity extends Similarity {
private final float queryWeight;
final float[] normTable;
- public TFIDFScorer(String field, float boost, Explanation idf, float[] normTable) {
- super(field);
+ public TFIDFScorer(float boost, Explanation idf, float[] normTable) {
// TODO: Validate?
this.idf = idf;
this.boost = boost;
diff --git a/lucene/core/src/java/org/apache/lucene/search/spans/SpanWeight.java b/lucene/core/src/java/org/apache/lucene/search/spans/SpanWeight.java
index 25b58fd..35c36d7 100644
--- a/lucene/core/src/java/org/apache/lucene/search/spans/SpanWeight.java
+++ b/lucene/core/src/java/org/apache/lucene/search/spans/SpanWeight.java
@@ -140,7 +140,7 @@ public abstract class SpanWeight extends Weight {
* @throws IOException on error
*/
public LeafSimScorer getSimScorer(LeafReaderContext context) throws IOException {
- return simScorer == null ? null : new LeafSimScorer(simScorer, context.reader(), true, Float.MAX_VALUE);
+ return simScorer == null ? null : new LeafSimScorer(simScorer, context.reader(), field, true);
}
@Override
@@ -150,7 +150,7 @@ public abstract class SpanWeight extends Weight {
int newDoc = scorer.iterator().advance(doc);
if (newDoc == doc) {
float freq = scorer.sloppyFreq();
- LeafSimScorer docScorer = new LeafSimScorer(simScorer, context.reader(), true, Float.MAX_VALUE);
+ LeafSimScorer docScorer = new LeafSimScorer(simScorer, context.reader(), field, true);
Explanation freqExplanation = Explanation.match(freq, "phraseFreq=" + freq);
Explanation scoreExplanation = docScorer.explain(doc, freqExplanation);
return Explanation.match(scoreExplanation.getValue(),
diff --git a/lucene/core/src/test/org/apache/lucene/document/TestFeatureField.java b/lucene/core/src/test/org/apache/lucene/document/TestFeatureField.java
index 2afc250..95194b7 100644
--- a/lucene/core/src/test/org/apache/lucene/document/TestFeatureField.java
+++ b/lucene/core/src/test/org/apache/lucene/document/TestFeatureField.java
@@ -206,15 +206,15 @@ public class TestFeatureField extends LuceneTestCase {
}
public void testLogSimScorer() {
- doTestSimScorer(new FeatureField.LogFunction(4.5f).scorer("foo", 3f));
+ doTestSimScorer(new FeatureField.LogFunction(4.5f).scorer(3f));
}
public void testSatuSimScorer() {
- doTestSimScorer(new FeatureField.SaturationFunction(20f).scorer("foo", 3f));
+ doTestSimScorer(new FeatureField.SaturationFunction(20f).scorer(3f));
}
public void testSigmSimScorer() {
- doTestSimScorer(new FeatureField.SigmoidFunction(20f, 0.6f).scorer("foo", 3f));
+ doTestSimScorer(new FeatureField.SigmoidFunction(20f, 0.6f).scorer(3f));
}
private void doTestSimScorer(SimScorer s) {
diff --git a/lucene/core/src/test/org/apache/lucene/index/TestMaxTermFrequency.java b/lucene/core/src/test/org/apache/lucene/index/TestMaxTermFrequency.java
index 216dc21..8297f59 100644
--- a/lucene/core/src/test/org/apache/lucene/index/TestMaxTermFrequency.java
+++ b/lucene/core/src/test/org/apache/lucene/index/TestMaxTermFrequency.java
@@ -109,7 +109,7 @@ public class TestMaxTermFrequency extends LuceneTestCase {
@Override
public SimScorer scorer(float boost, CollectionStatistics collectionStats, TermStatistics... termStats) {
- return new SimScorer(collectionStats.field()) {
+ return new SimScorer() {
@Override
public float score(float freq, long norm) {
diff --git a/lucene/core/src/test/org/apache/lucene/search/TestBooleanQueryVisitSubscorers.java b/lucene/core/src/test/org/apache/lucene/search/TestBooleanQueryVisitSubscorers.java
index 065a6de..e28e090 100644
--- a/lucene/core/src/test/org/apache/lucene/search/TestBooleanQueryVisitSubscorers.java
+++ b/lucene/core/src/test/org/apache/lucene/search/TestBooleanQueryVisitSubscorers.java
@@ -329,7 +329,7 @@ public class TestBooleanQueryVisitSubscorers extends LuceneTestCase {
@Override
public SimScorer scorer(float boost, CollectionStatistics collectionStats, TermStatistics... termStats) {
- return new SimScorer(collectionStats.field()) {
+ return new SimScorer() {
@Override
public float score(float freq, long norm) {
return freq;
diff --git a/lucene/core/src/test/org/apache/lucene/search/TestConjunctions.java b/lucene/core/src/test/org/apache/lucene/search/TestConjunctions.java
index 4cfa4d3..cc4f7fe 100644
--- a/lucene/core/src/test/org/apache/lucene/search/TestConjunctions.java
+++ b/lucene/core/src/test/org/apache/lucene/search/TestConjunctions.java
@@ -101,7 +101,7 @@ public class TestConjunctions extends LuceneTestCase {
@Override
public SimScorer scorer(float boost,
CollectionStatistics collectionStats, TermStatistics... termStats) {
- return new SimScorer(collectionStats.field()) {
+ return new SimScorer() {
@Override
public float score(float freq, long norm) {
return freq;
diff --git a/lucene/core/src/test/org/apache/lucene/search/TestMinShouldMatch2.java b/lucene/core/src/test/org/apache/lucene/search/TestMinShouldMatch2.java
index c98c164..ea414e7 100644
--- a/lucene/core/src/test/org/apache/lucene/search/TestMinShouldMatch2.java
+++ b/lucene/core/src/test/org/apache/lucene/search/TestMinShouldMatch2.java
@@ -333,7 +333,7 @@ public class TestMinShouldMatch2 extends LuceneTestCase {
SimScorer w = weight.similarity.scorer(1f,
searcher.collectionStatistics("field"),
searcher.termStatistics(term, context));
- sims[(int)ord] = new LeafSimScorer(w, reader, true, 1);
+ sims[(int)ord] = new LeafSimScorer(w, reader, "field", true);
}
}
}
diff --git a/lucene/core/src/test/org/apache/lucene/search/TestSimilarityProvider.java b/lucene/core/src/test/org/apache/lucene/search/TestSimilarityProvider.java
index f360bed..15411c4 100644
--- a/lucene/core/src/test/org/apache/lucene/search/TestSimilarityProvider.java
+++ b/lucene/core/src/test/org/apache/lucene/search/TestSimilarityProvider.java
@@ -111,7 +111,7 @@ public class TestSimilarityProvider extends LuceneTestCase {
@Override
public SimScorer scorer(float boost, CollectionStatistics collectionStats, TermStatistics... termStats) {
- return new SimScorer(collectionStats.field()) {
+ return new SimScorer() {
@Override
public float score(float freq, long norm) {
@@ -131,7 +131,7 @@ public class TestSimilarityProvider extends LuceneTestCase {
@Override
public SimScorer scorer(float boost, CollectionStatistics collectionStats, TermStatistics... termStats) {
- return new SimScorer(collectionStats.field()) {
+ return new SimScorer() {
@Override
public float score(float freq, long norm) {
return 10;
diff --git a/lucene/core/src/test/org/apache/lucene/search/TestSubScorerFreqs.java b/lucene/core/src/test/org/apache/lucene/search/TestSubScorerFreqs.java
index f45e304..699f8b9 100644
--- a/lucene/core/src/test/org/apache/lucene/search/TestSubScorerFreqs.java
+++ b/lucene/core/src/test/org/apache/lucene/search/TestSubScorerFreqs.java
@@ -231,7 +231,7 @@ public class TestSubScorerFreqs extends LuceneTestCase {
@Override
public SimScorer scorer(float boost, CollectionStatistics collectionStats, TermStatistics... termStats) {
- return new SimScorer(collectionStats.field()) {
+ return new SimScorer() {
@Override
public float score(float freq, long norm) {
return freq;
diff --git a/lucene/queries/src/java/org/apache/lucene/queries/function/valuesource/NormValueSource.java b/lucene/queries/src/java/org/apache/lucene/queries/function/valuesource/NormValueSource.java
index 662f80d..ffbb0c5 100644
--- a/lucene/queries/src/java/org/apache/lucene/queries/function/valuesource/NormValueSource.java
+++ b/lucene/queries/src/java/org/apache/lucene/queries/function/valuesource/NormValueSource.java
@@ -71,7 +71,7 @@ public class NormValueSource extends ValueSource {
final SimScorer simScorer = similarity.scorer(1f,
new CollectionStatistics(field, 1, 1, 1, 1),
new TermStatistics(new BytesRef("bogus"), 1, 1));
- final LeafSimScorer leafSimScorer = new LeafSimScorer(simScorer, readerContext.reader(), true, Float.MAX_VALUE);
+ final LeafSimScorer leafSimScorer = new LeafSimScorer(simScorer, readerContext.reader(), field, true);
return new FloatDocValues(this) {
int lastDocID = -1;
diff --git a/lucene/sandbox/src/java/org/apache/lucene/search/TermAutomatonQuery.java b/lucene/sandbox/src/java/org/apache/lucene/search/TermAutomatonQuery.java
index 42a5f74..81426a7 100644
--- a/lucene/sandbox/src/java/org/apache/lucene/search/TermAutomatonQuery.java
+++ b/lucene/sandbox/src/java/org/apache/lucene/search/TermAutomatonQuery.java
@@ -397,7 +397,7 @@ public class TermAutomatonQuery extends Query {
}
if (any) {
- return new TermAutomatonScorer(this, enums, anyTermID, idToTerm, new LeafSimScorer(stats, context.reader(), true, Float.MAX_VALUE));
+ return new TermAutomatonScorer(this, enums, anyTermID, idToTerm, new LeafSimScorer(stats, context.reader(), field, true));
} else {
return null;
}
diff --git a/lucene/sandbox/src/java/org/apache/lucene/search/TermAutomatonScorer.java b/lucene/sandbox/src/java/org/apache/lucene/search/TermAutomatonScorer.java
index f1ab32f..6887a4c 100644
--- a/lucene/sandbox/src/java/org/apache/lucene/search/TermAutomatonScorer.java
+++ b/lucene/sandbox/src/java/org/apache/lucene/search/TermAutomatonScorer.java
@@ -361,7 +361,7 @@ class TermAutomatonScorer extends Scorer {
@Override
public float getMaxScore(int upTo) throws IOException {
- return docScorer.maxScore();
+ return docScorer.getSimScorer().score(Float.MAX_VALUE, 1L);
}
static class TermRunAutomaton extends RunAutomaton {
diff --git a/lucene/sandbox/src/java/org/apache/lucene/search/intervals/IntervalQuery.java b/lucene/sandbox/src/java/org/apache/lucene/search/intervals/IntervalQuery.java
index 934d553..306c059 100644
--- a/lucene/sandbox/src/java/org/apache/lucene/search/intervals/IntervalQuery.java
+++ b/lucene/sandbox/src/java/org/apache/lucene/search/intervals/IntervalQuery.java
@@ -142,7 +142,7 @@ public final class IntervalQuery extends Query {
if (intervals == null)
return null;
LeafSimScorer leafScorer = simScorer == null ? null
- : new LeafSimScorer(simScorer, context.reader(), scoreMode.needsScores(), Float.MAX_VALUE);
+ : new LeafSimScorer(simScorer, context.reader(), field, scoreMode.needsScores());
return new IntervalScorer(this, intervals, leafScorer);
}
diff --git a/lucene/test-framework/src/java/org/apache/lucene/search/similarities/AssertingSimilarity.java b/lucene/test-framework/src/java/org/apache/lucene/search/similarities/AssertingSimilarity.java
index 0eaf738..c448312 100644
--- a/lucene/test-framework/src/java/org/apache/lucene/search/similarities/AssertingSimilarity.java
+++ b/lucene/test-framework/src/java/org/apache/lucene/search/similarities/AssertingSimilarity.java
@@ -65,7 +65,7 @@ public class AssertingSimilarity extends Similarity {
final float boost;
AssertingSimScorer(SimScorer delegate, float boost) {
- super(delegate.getField());
+ super();
this.delegate = delegate;
this.boost = boost;
}