Skip to content

Apache Lucene open-source search software

Removed Scorer#getWeight (#13440)

Sanjay Duttd0d2aa274fb5
diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt
index 850c9f023eb..d682498c726 100644
--- a/lucene/CHANGES.txt
+++ b/lucene/CHANGES.txt
@@ -110,6 +110,8 @@ API Changes
I/O for top-level disjunctions. Weight#bulkScorer() still exists for compatibility, but delegates
to ScorerSupplier#bulkScorer(). (Adrien Grand)
+* GITHUB#13410: Removed Scorer#getWeight (Sanjay Dutt, Adrien Grand)
+
New Features
---------------------
diff --git a/lucene/MIGRATE.md b/lucene/MIGRATE.md
index 1a2f622b728..64de353b153 100644
--- a/lucene/MIGRATE.md
+++ b/lucene/MIGRATE.md
@@ -779,3 +779,17 @@ to manage the indexed data on their own and create new `Facet` implementations t
The `Weight#scorerSupplier` method is now declared abstract, compelling child classes to implement the ScorerSupplier
interface. Additionally, `Weight#scorer` is now declared final, with its implementation being delegated to
`Weight#scorerSupplier` for the scorer.
+
+### Reference to `weight` is removed from Scorer (GITHUB#13410)
+
+The `weight` has been removed from the Scorer class. Consequently, the constructor, `Scorer(Weight)`,and a getter,
+`Scorer#getWeight`, has also been eliminated. References to weight have also been removed from nearly all the subclasses
+of Scorer, including ConstantScoreScorer, TermScorer, and others.
+
+Additionally, several APIs have been modified to remove the weight reference, as it is no longer necessary.
+Specifically, the method `FunctionValues#getScorer(Weight weight, LeafReaderContext readerContext)` has been updated to
+`FunctionValues#getScorer(LeafReaderContext readerContext)`.
+
+Callers must now keep track of the Weight instance that created the Scorer if they need it, instead of relying on
+Scorer.
+
diff --git a/lucene/core/src/java/org/apache/lucene/document/BaseShapeDocValuesQuery.java b/lucene/core/src/java/org/apache/lucene/document/BaseShapeDocValuesQuery.java
index 7f1c4c1c1a2..9de956bb039 100644
--- a/lucene/core/src/java/org/apache/lucene/document/BaseShapeDocValuesQuery.java
+++ b/lucene/core/src/java/org/apache/lucene/document/BaseShapeDocValuesQuery.java
@@ -25,7 +25,6 @@ import org.apache.lucene.index.FieldInfo;
import org.apache.lucene.index.LeafReader;
import org.apache.lucene.index.PointValues.Relation;
import org.apache.lucene.search.ConstantScoreScorer;
-import org.apache.lucene.search.ConstantScoreWeight;
import org.apache.lucene.search.ScoreMode;
import org.apache.lucene.search.Scorer;
import org.apache.lucene.search.ScorerSupplier;
@@ -59,7 +58,6 @@ abstract class BaseShapeDocValuesQuery extends SpatialQuery {
LeafReader reader,
SpatialVisitor spatialVisitor,
ScoreMode scoreMode,
- ConstantScoreWeight weight,
float boost,
float score)
throws IOException {
@@ -89,7 +87,7 @@ abstract class BaseShapeDocValuesQuery extends SpatialQuery {
@Override
public Scorer get(long leadCost) {
- return new ConstantScoreScorer(weight, boost, scoreMode, iterator);
+ return new ConstantScoreScorer(boost, scoreMode, iterator);
}
@Override
diff --git a/lucene/core/src/java/org/apache/lucene/document/BinaryRangeFieldRangeQuery.java b/lucene/core/src/java/org/apache/lucene/document/BinaryRangeFieldRangeQuery.java
index c66281498be..140227746f0 100644
--- a/lucene/core/src/java/org/apache/lucene/document/BinaryRangeFieldRangeQuery.java
+++ b/lucene/core/src/java/org/apache/lucene/document/BinaryRangeFieldRangeQuery.java
@@ -135,7 +135,7 @@ abstract class BinaryRangeFieldRangeQuery extends Query {
}
};
- final var scorer = new ConstantScoreScorer(this, score(), scoreMode, iterator);
+ final var scorer = new ConstantScoreScorer(score(), scoreMode, iterator);
return new DefaultScorerSupplier(scorer);
}
diff --git a/lucene/core/src/java/org/apache/lucene/document/LatLonDocValuesBoxQuery.java b/lucene/core/src/java/org/apache/lucene/document/LatLonDocValuesBoxQuery.java
index feed4a85f57..ac01e4c74f3 100644
--- a/lucene/core/src/java/org/apache/lucene/document/LatLonDocValuesBoxQuery.java
+++ b/lucene/core/src/java/org/apache/lucene/document/LatLonDocValuesBoxQuery.java
@@ -153,7 +153,7 @@ final class LatLonDocValuesBoxQuery extends Query {
return 5; // 5 comparisons
}
};
- final var scorer = new ConstantScoreScorer(this, boost, scoreMode, iterator);
+ final var scorer = new ConstantScoreScorer(boost, scoreMode, iterator);
return new DefaultScorerSupplier(scorer);
}
diff --git a/lucene/core/src/java/org/apache/lucene/document/LatLonDocValuesQuery.java b/lucene/core/src/java/org/apache/lucene/document/LatLonDocValuesQuery.java
index 86dc574191f..45a7bc0eb52 100644
--- a/lucene/core/src/java/org/apache/lucene/document/LatLonDocValuesQuery.java
+++ b/lucene/core/src/java/org/apache/lucene/document/LatLonDocValuesQuery.java
@@ -158,7 +158,7 @@ class LatLonDocValuesQuery extends Query {
throw new IllegalArgumentException(
"Invalid query relationship:[" + queryRelation + "]");
}
- final var scorer = new ConstantScoreScorer(this, boost, scoreMode, iterator);
+ final var scorer = new ConstantScoreScorer(boost, scoreMode, iterator);
return new DefaultScorerSupplier(scorer);
}
diff --git a/lucene/core/src/java/org/apache/lucene/document/LatLonPointDistanceFeatureQuery.java b/lucene/core/src/java/org/apache/lucene/document/LatLonPointDistanceFeatureQuery.java
index b10eab2cda1..df296c15ab5 100644
--- a/lucene/core/src/java/org/apache/lucene/document/LatLonPointDistanceFeatureQuery.java
+++ b/lucene/core/src/java/org/apache/lucene/document/LatLonPointDistanceFeatureQuery.java
@@ -215,14 +215,12 @@ final class LatLonPointDistanceFeatureQuery extends Query {
final SortedNumericDocValues multiDocValues =
DocValues.getSortedNumeric(context.reader(), field);
final NumericDocValues docValues = selectValues(multiDocValues);
-
- final Weight weight = this;
return new ScorerSupplier() {
@Override
public Scorer get(long leadCost) throws IOException {
return new DistanceScorer(
- weight, context.reader().maxDoc(), leadCost, boost, pointValues, docValues);
+ context.reader().maxDoc(), leadCost, boost, pointValues, docValues);
}
@Override
@@ -258,13 +256,11 @@ final class LatLonPointDistanceFeatureQuery extends Query {
private double maxDistance = GeoUtils.EARTH_MEAN_RADIUS_METERS * Math.PI;
protected DistanceScorer(
- Weight weight,
int maxDoc,
long leadCost,
float boost,
PointValues pointValues,
NumericDocValues docValues) {
- super(weight);
this.maxDoc = maxDoc;
this.leadCost = leadCost;
this.boost = boost;
diff --git a/lucene/core/src/java/org/apache/lucene/document/LatLonPointDistanceQuery.java b/lucene/core/src/java/org/apache/lucene/document/LatLonPointDistanceQuery.java
index 34f3d16750e..7f5f8cf6290 100644
--- a/lucene/core/src/java/org/apache/lucene/document/LatLonPointDistanceQuery.java
+++ b/lucene/core/src/java/org/apache/lucene/document/LatLonPointDistanceQuery.java
@@ -137,7 +137,6 @@ final class LatLonPointDistanceQuery extends Query {
DocIdSetBuilder result = new DocIdSetBuilder(reader.maxDoc(), values, field);
final IntersectVisitor visitor = getIntersectVisitor(result);
- final Weight weight = this;
return new ScorerSupplier() {
long cost = -1;
@@ -155,10 +154,10 @@ final class LatLonPointDistanceQuery extends Query {
long[] cost = new long[] {reader.maxDoc()};
values.intersect(getInverseIntersectVisitor(result, cost));
final DocIdSetIterator iterator = new BitSetIterator(result, cost[0]);
- return new ConstantScoreScorer(weight, score(), scoreMode, iterator);
+ return new ConstantScoreScorer(score(), scoreMode, iterator);
}
values.intersect(visitor);
- return new ConstantScoreScorer(weight, score(), scoreMode, result.build().iterator());
+ return new ConstantScoreScorer(score(), scoreMode, result.build().iterator());
}
@Override
diff --git a/lucene/core/src/java/org/apache/lucene/document/LongDistanceFeatureQuery.java b/lucene/core/src/java/org/apache/lucene/document/LongDistanceFeatureQuery.java
index 58cb747bf7f..c675136ca80 100644
--- a/lucene/core/src/java/org/apache/lucene/document/LongDistanceFeatureQuery.java
+++ b/lucene/core/src/java/org/apache/lucene/document/LongDistanceFeatureQuery.java
@@ -205,14 +205,12 @@ final class LongDistanceFeatureQuery extends Query {
final SortedNumericDocValues multiDocValues =
DocValues.getSortedNumeric(context.reader(), field);
final NumericDocValues docValues = selectValues(multiDocValues);
-
- final Weight weight = this;
return new ScorerSupplier() {
@Override
public Scorer get(long leadCost) throws IOException {
return new DistanceScorer(
- weight, context.reader().maxDoc(), leadCost, boost, pointValues, docValues);
+ context.reader().maxDoc(), leadCost, boost, pointValues, docValues);
}
@Override
@@ -236,13 +234,11 @@ final class LongDistanceFeatureQuery extends Query {
private long maxDistance = Long.MAX_VALUE;
protected DistanceScorer(
- Weight weight,
int maxDoc,
long leadCost,
float boost,
PointValues pointValues,
NumericDocValues docValues) {
- super(weight);
this.maxDoc = maxDoc;
this.leadCost = leadCost;
this.boost = boost;
diff --git a/lucene/core/src/java/org/apache/lucene/document/RangeFieldQuery.java b/lucene/core/src/java/org/apache/lucene/document/RangeFieldQuery.java
index 00b96b960d2..f5747c0f8bd 100644
--- a/lucene/core/src/java/org/apache/lucene/document/RangeFieldQuery.java
+++ b/lucene/core/src/java/org/apache/lucene/document/RangeFieldQuery.java
@@ -459,13 +459,12 @@ public abstract class RangeFieldQuery extends Query {
allDocsMatch = true;
}
- final Weight weight = this;
if (allDocsMatch) {
return new ScorerSupplier() {
@Override
public Scorer get(long leadCost) {
return new ConstantScoreScorer(
- weight, score(), scoreMode, DocIdSetIterator.all(reader.maxDoc()));
+ score(), scoreMode, DocIdSetIterator.all(reader.maxDoc()));
}
@Override
@@ -484,7 +483,7 @@ public abstract class RangeFieldQuery extends Query {
public Scorer get(long leadCost) throws IOException {
values.intersect(visitor);
DocIdSetIterator iterator = result.build().iterator();
- return new ConstantScoreScorer(weight, score(), scoreMode, iterator);
+ return new ConstantScoreScorer(score(), scoreMode, iterator);
}
@Override
diff --git a/lucene/core/src/java/org/apache/lucene/document/SortedNumericDocValuesRangeQuery.java b/lucene/core/src/java/org/apache/lucene/document/SortedNumericDocValuesRangeQuery.java
index 424f9473fa5..abbbeae571c 100644
--- a/lucene/core/src/java/org/apache/lucene/document/SortedNumericDocValuesRangeQuery.java
+++ b/lucene/core/src/java/org/apache/lucene/document/SortedNumericDocValuesRangeQuery.java
@@ -149,7 +149,7 @@ final class SortedNumericDocValuesRangeQuery extends Query {
}
};
}
- final var scorer = new ConstantScoreScorer(this, score(), scoreMode, iterator);
+ final var scorer = new ConstantScoreScorer(score(), scoreMode, iterator);
return new DefaultScorerSupplier(scorer);
}
};
diff --git a/lucene/core/src/java/org/apache/lucene/document/SortedNumericDocValuesSetQuery.java b/lucene/core/src/java/org/apache/lucene/document/SortedNumericDocValuesSetQuery.java
index b5596a67221..192a751b43e 100644
--- a/lucene/core/src/java/org/apache/lucene/document/SortedNumericDocValuesSetQuery.java
+++ b/lucene/core/src/java/org/apache/lucene/document/SortedNumericDocValuesSetQuery.java
@@ -150,7 +150,7 @@ final class SortedNumericDocValuesSetQuery extends Query implements Accountable
}
};
}
- final var scorer = new ConstantScoreScorer(this, score(), scoreMode, iterator);
+ final var scorer = new ConstantScoreScorer(score(), scoreMode, iterator);
return new DefaultScorerSupplier(scorer);
}
};
diff --git a/lucene/core/src/java/org/apache/lucene/document/SortedSetDocValuesRangeQuery.java b/lucene/core/src/java/org/apache/lucene/document/SortedSetDocValuesRangeQuery.java
index 03cea17b3b9..0c9959b8756 100644
--- a/lucene/core/src/java/org/apache/lucene/document/SortedSetDocValuesRangeQuery.java
+++ b/lucene/core/src/java/org/apache/lucene/document/SortedSetDocValuesRangeQuery.java
@@ -110,7 +110,6 @@ final class SortedSetDocValuesRangeQuery extends Query {
return new ConstantScoreWeight(this, boost) {
@Override
public ScorerSupplier scorerSupplier(LeafReaderContext context) throws IOException {
- final Weight weight = this;
if (context.reader().getFieldInfos().fieldInfo(field) == null) {
return null;
}
@@ -151,7 +150,7 @@ final class SortedSetDocValuesRangeQuery extends Query {
// no terms matched in this segment
if (minOrd > maxOrd) {
- return new ConstantScoreScorer(weight, score(), scoreMode, DocIdSetIterator.empty());
+ return new ConstantScoreScorer(score(), scoreMode, DocIdSetIterator.empty());
}
final SortedDocValues singleton = DocValues.unwrapSingleton(values);
@@ -193,7 +192,7 @@ final class SortedSetDocValuesRangeQuery extends Query {
}
};
}
- return new ConstantScoreScorer(weight, score(), scoreMode, iterator);
+ return new ConstantScoreScorer(score(), scoreMode, iterator);
}
@Override
diff --git a/lucene/core/src/java/org/apache/lucene/document/SpatialQuery.java b/lucene/core/src/java/org/apache/lucene/document/SpatialQuery.java
index 836ca974bc5..811591d9a1c 100644
--- a/lucene/core/src/java/org/apache/lucene/document/SpatialQuery.java
+++ b/lucene/core/src/java/org/apache/lucene/document/SpatialQuery.java
@@ -150,7 +150,6 @@ abstract class SpatialQuery extends Query {
LeafReader reader,
SpatialVisitor spatialVisitor,
ScoreMode scoreMode,
- ConstantScoreWeight weight,
float boost,
float score)
throws IOException {
@@ -178,8 +177,7 @@ abstract class SpatialQuery extends Query {
return new ScorerSupplier() {
@Override
public Scorer get(long leadCost) {
- return new ConstantScoreScorer(
- weight, score, scoreMode, DocIdSetIterator.all(reader.maxDoc()));
+ return new ConstantScoreScorer(score, scoreMode, DocIdSetIterator.all(reader.maxDoc()));
}
@Override
@@ -200,7 +198,7 @@ abstract class SpatialQuery extends Query {
return new RelationScorerSupplier(values, spatialVisitor, queryRelation, field) {
@Override
public Scorer get(long leadCost) throws IOException {
- return getScorer(reader, weight, score, scoreMode);
+ return getScorer(reader, score, scoreMode);
}
};
}
@@ -215,7 +213,7 @@ abstract class SpatialQuery extends Query {
@Override
public ScorerSupplier scorerSupplier(LeafReaderContext context) throws IOException {
final LeafReader reader = context.reader();
- return getScorerSupplier(reader, spatialVisitor, scoreMode, this, boost, score());
+ return getScorerSupplier(reader, spatialVisitor, scoreMode, boost, score());
}
@Override
@@ -291,18 +289,17 @@ abstract class SpatialQuery extends Query {
}
protected Scorer getScorer(
- final LeafReader reader, final Weight weight, final float boost, final ScoreMode scoreMode)
- throws IOException {
+ final LeafReader reader, final float boost, final ScoreMode scoreMode) throws IOException {
switch (queryRelation) {
case INTERSECTS:
- return getSparseScorer(reader, weight, boost, scoreMode);
+ return getSparseScorer(reader, boost, scoreMode);
case CONTAINS:
- return getContainsDenseScorer(reader, weight, boost, scoreMode);
+ return getContainsDenseScorer(reader, boost, scoreMode);
case WITHIN:
case DISJOINT:
return values.getDocCount() == values.size()
- ? getSparseScorer(reader, weight, boost, scoreMode)
- : getDenseScorer(reader, weight, boost, scoreMode);
+ ? getSparseScorer(reader, boost, scoreMode)
+ : getDenseScorer(reader, boost, scoreMode);
default:
throw new IllegalArgumentException("Unsupported query type :[" + queryRelation + "]");
}
@@ -310,8 +307,7 @@ abstract class SpatialQuery extends Query {
/** Scorer used for INTERSECTS and single value points */
private Scorer getSparseScorer(
- final LeafReader reader, final Weight weight, final float boost, final ScoreMode scoreMode)
- throws IOException {
+ final LeafReader reader, final float boost, final ScoreMode scoreMode) throws IOException {
if (queryRelation == QueryRelation.DISJOINT
&& values.getDocCount() == reader.maxDoc()
&& values.getDocCount() == values.size()
@@ -324,7 +320,7 @@ abstract class SpatialQuery extends Query {
final long[] cost = new long[] {reader.maxDoc()};
values.intersect(getInverseDenseVisitor(spatialVisitor, queryRelation, result, cost));
final DocIdSetIterator iterator = new BitSetIterator(result, cost[0]);
- return new ConstantScoreScorer(weight, boost, scoreMode, iterator);
+ return new ConstantScoreScorer(boost, scoreMode, iterator);
} else if (values.getDocCount() < (values.size() >>> 2)) {
// we use a dense structure so we can skip already visited documents
final FixedBitSet result = new FixedBitSet(reader.maxDoc());
@@ -333,18 +329,17 @@ abstract class SpatialQuery extends Query {
assert cost[0] > 0 || result.cardinality() == 0;
final DocIdSetIterator iterator =
cost[0] == 0 ? DocIdSetIterator.empty() : new BitSetIterator(result, cost[0]);
- return new ConstantScoreScorer(weight, boost, scoreMode, iterator);
+ return new ConstantScoreScorer(boost, scoreMode, iterator);
} else {
final DocIdSetBuilder docIdSetBuilder = new DocIdSetBuilder(reader.maxDoc(), values, field);
values.intersect(getSparseVisitor(spatialVisitor, queryRelation, docIdSetBuilder));
final DocIdSetIterator iterator = docIdSetBuilder.build().iterator();
- return new ConstantScoreScorer(weight, boost, scoreMode, iterator);
+ return new ConstantScoreScorer(boost, scoreMode, iterator);
}
}
/** Scorer used for WITHIN and DISJOINT */
- private Scorer getDenseScorer(
- LeafReader reader, Weight weight, final float boost, ScoreMode scoreMode)
+ private Scorer getDenseScorer(LeafReader reader, final float boost, ScoreMode scoreMode)
throws IOException {
final FixedBitSet result = new FixedBitSet(reader.maxDoc());
final long[] cost;
@@ -369,11 +364,10 @@ abstract class SpatialQuery extends Query {
assert cost[0] > 0 || result.cardinality() == 0;
final DocIdSetIterator iterator =
cost[0] == 0 ? DocIdSetIterator.empty() : new BitSetIterator(result, cost[0]);
- return new ConstantScoreScorer(weight, boost, scoreMode, iterator);
+ return new ConstantScoreScorer(boost, scoreMode, iterator);
}
- private Scorer getContainsDenseScorer(
- LeafReader reader, Weight weight, final float boost, ScoreMode scoreMode)
+ private Scorer getContainsDenseScorer(LeafReader reader, final float boost, ScoreMode scoreMode)
throws IOException {
final FixedBitSet result = new FixedBitSet(reader.maxDoc());
final long[] cost = new long[] {0};
@@ -385,7 +379,7 @@ abstract class SpatialQuery extends Query {
assert cost[0] > 0 || result.cardinality() == 0;
final DocIdSetIterator iterator =
cost[0] == 0 ? DocIdSetIterator.empty() : new BitSetIterator(result, cost[0]);
- return new ConstantScoreScorer(weight, boost, scoreMode, iterator);
+ return new ConstantScoreScorer(boost, scoreMode, iterator);
}
@Override
diff --git a/lucene/core/src/java/org/apache/lucene/document/XYDocValuesPointInGeometryQuery.java b/lucene/core/src/java/org/apache/lucene/document/XYDocValuesPointInGeometryQuery.java
index be297a142d6..132a3a36308 100644
--- a/lucene/core/src/java/org/apache/lucene/document/XYDocValuesPointInGeometryQuery.java
+++ b/lucene/core/src/java/org/apache/lucene/document/XYDocValuesPointInGeometryQuery.java
@@ -130,7 +130,7 @@ public class XYDocValuesPointInGeometryQuery extends Query {
return 1000f; // TODO: what should it be?
}
};
- final var scorer = new ConstantScoreScorer(this, boost, scoreMode, iterator);
+ final var scorer = new ConstantScoreScorer(boost, scoreMode, iterator);
return new DefaultScorerSupplier(scorer);
}
diff --git a/lucene/core/src/java/org/apache/lucene/document/XYPointInGeometryQuery.java b/lucene/core/src/java/org/apache/lucene/document/XYPointInGeometryQuery.java
index 107ecd0ffd9..47b6abb46c2 100644
--- a/lucene/core/src/java/org/apache/lucene/document/XYPointInGeometryQuery.java
+++ b/lucene/core/src/java/org/apache/lucene/document/XYPointInGeometryQuery.java
@@ -141,7 +141,6 @@ final class XYPointInGeometryQuery extends Query {
return null;
}
XYPointField.checkCompatible(fieldInfo);
- final Weight weight = this;
return new ScorerSupplier() {
@@ -152,7 +151,7 @@ final class XYPointInGeometryQuery extends Query {
@Override
public Scorer get(long leadCost) throws IOException {
values.intersect(visitor);
- return new ConstantScoreScorer(weight, score(), scoreMode, result.build().iterator());
+ return new ConstantScoreScorer(score(), scoreMode, result.build().iterator());
}
@Override
diff --git a/lucene/core/src/java/org/apache/lucene/search/AbstractKnnVectorQuery.java b/lucene/core/src/java/org/apache/lucene/search/AbstractKnnVectorQuery.java
index 32dc09c3a9f..8fceb0cfec5 100644
--- a/lucene/core/src/java/org/apache/lucene/search/AbstractKnnVectorQuery.java
+++ b/lucene/core/src/java/org/apache/lucene/search/AbstractKnnVectorQuery.java
@@ -388,7 +388,7 @@ abstract class AbstractKnnVectorQuery extends Query {
return null;
}
final var scorer =
- new Scorer(this) {
+ new Scorer() {
final int lower = segmentStarts[context.ord];
final int upper = segmentStarts[context.ord + 1];
int upTo = -1;
diff --git a/lucene/core/src/java/org/apache/lucene/search/AbstractMultiTermQueryConstantScoreWrapper.java b/lucene/core/src/java/org/apache/lucene/search/AbstractMultiTermQueryConstantScoreWrapper.java
index 1a9b18f0f39..cfd0f48147c 100644
--- a/lucene/core/src/java/org/apache/lucene/search/AbstractMultiTermQueryConstantScoreWrapper.java
+++ b/lucene/core/src/java/org/apache/lucene/search/AbstractMultiTermQueryConstantScoreWrapper.java
@@ -208,7 +208,7 @@ abstract class AbstractMultiTermQueryConstantScoreWrapper<Q extends MultiTermQue
if (iterator == null) {
return null;
}
- return new ConstantScoreScorer(this, score(), scoreMode, iterator);
+ return new ConstantScoreScorer(score(), scoreMode, iterator);
}
@Override
@@ -232,8 +232,6 @@ abstract class AbstractMultiTermQueryConstantScoreWrapper<Q extends MultiTermQue
}
final long cost = estimateCost(terms, q.getTermsCount());
-
- final Weight weight = this;
return new ScorerSupplier() {
@Override
public Scorer get(long leadCost) throws IOException {
@@ -252,8 +250,7 @@ abstract class AbstractMultiTermQueryConstantScoreWrapper<Q extends MultiTermQue
// find that there are actually no hits, we need to return an empty Scorer as opposed
// to null:
return Objects.requireNonNullElseGet(
- scorer,
- () -> new ConstantScoreScorer(weight, score(), scoreMode, DocIdSetIterator.empty()));
+ scorer, () -> new ConstantScoreScorer(score(), scoreMode, DocIdSetIterator.empty()));
}
@Override
@@ -267,7 +264,7 @@ abstract class AbstractMultiTermQueryConstantScoreWrapper<Q extends MultiTermQue
} else {
bulkScorer =
new DefaultBulkScorer(
- new ConstantScoreScorer(weight, score(), scoreMode, weightOrIterator.iterator));
+ new ConstantScoreScorer(score(), scoreMode, weightOrIterator.iterator));
}
// It's against the API contract to return a null scorer from a non-null ScoreSupplier.
@@ -278,8 +275,7 @@ abstract class AbstractMultiTermQueryConstantScoreWrapper<Q extends MultiTermQue
bulkScorer,
() ->
new DefaultBulkScorer(
- new ConstantScoreScorer(
- weight, score(), scoreMode, DocIdSetIterator.empty())));
+ new ConstantScoreScorer(score(), scoreMode, DocIdSetIterator.empty())));
}
@Override
diff --git a/lucene/core/src/java/org/apache/lucene/search/AbstractVectorSimilarityQuery.java b/lucene/core/src/java/org/apache/lucene/search/AbstractVectorSimilarityQuery.java
index c55ea308e76..77a5ff6f24f 100644
--- a/lucene/core/src/java/org/apache/lucene/search/AbstractVectorSimilarityQuery.java
+++ b/lucene/core/src/java/org/apache/lucene/search/AbstractVectorSimilarityQuery.java
@@ -201,8 +201,7 @@ abstract class AbstractVectorSimilarityQuery extends Query {
final DocIdSetIterator iterator;
final float[] cachedScore;
- VectorSimilarityScorer(Weight weight, DocIdSetIterator iterator, float[] cachedScore) {
- super(weight);
+ VectorSimilarityScorer(DocIdSetIterator iterator, float[] cachedScore) {
this.iterator = iterator;
this.cachedScore = cachedScore;
}
@@ -253,7 +252,7 @@ abstract class AbstractVectorSimilarityQuery extends Query {
}
};
- return new VectorSimilarityScorer(weight, iterator, cachedScore);
+ return new VectorSimilarityScorer(iterator, cachedScore);
}
static VectorSimilarityScorer fromAcceptDocs(
@@ -282,7 +281,7 @@ abstract class AbstractVectorSimilarityQuery extends Query {
}
};
- return new VectorSimilarityScorer(weight, iterator, cachedScore);
+ return new VectorSimilarityScorer(iterator, cachedScore);
}
@Override
diff --git a/lucene/core/src/java/org/apache/lucene/search/BlockMaxConjunctionScorer.java b/lucene/core/src/java/org/apache/lucene/search/BlockMaxConjunctionScorer.java
index 47ef5e07f19..76788185faa 100644
--- a/lucene/core/src/java/org/apache/lucene/search/BlockMaxConjunctionScorer.java
+++ b/lucene/core/src/java/org/apache/lucene/search/BlockMaxConjunctionScorer.java
@@ -34,8 +34,7 @@ final class BlockMaxConjunctionScorer extends Scorer {
float minScore;
/** Create a new {@link BlockMaxConjunctionScorer} from scoring clauses. */
- BlockMaxConjunctionScorer(Weight weight, Collection<Scorer> scorersList) throws IOException {
- super(weight);
+ BlockMaxConjunctionScorer(Collection<Scorer> scorersList) throws IOException {
this.scorers = scorersList.toArray(new Scorer[scorersList.size()]);
// Sort scorer by cost
Arrays.sort(this.scorers, Comparator.comparingLong(s -> s.iterator().cost()));
diff --git a/lucene/core/src/java/org/apache/lucene/search/BooleanScorerSupplier.java b/lucene/core/src/java/org/apache/lucene/search/BooleanScorerSupplier.java
index 4f957aad4be..b07d8ebb88e 100644
--- a/lucene/core/src/java/org/apache/lucene/search/BooleanScorerSupplier.java
+++ b/lucene/core/src/java/org/apache/lucene/search/BooleanScorerSupplier.java
@@ -31,8 +31,6 @@ import org.apache.lucene.search.Weight.DefaultBulkScorer;
import org.apache.lucene.util.Bits;
final class BooleanScorerSupplier extends ScorerSupplier {
-
- private final Weight weight;
private final Map<BooleanClause.Occur, Collection<ScorerSupplier>> subs;
private final ScoreMode scoreMode;
private final int minShouldMatch;
@@ -65,7 +63,6 @@ final class BooleanScorerSupplier extends ScorerSupplier {
== 0) {
throw new IllegalArgumentException("There should be at least one positive clause");
}
- this.weight = weight;
this.subs = subs;
this.scoreMode = scoreMode;
this.minShouldMatch = minShouldMatch;
@@ -121,8 +118,8 @@ final class BooleanScorerSupplier extends ScorerSupplier {
// no scoring clauses but scores are needed so we wrap the scorer in
// a constant score in order to allow early termination
return scorer.twoPhaseIterator() != null
- ? new ConstantScoreScorer(weight, 0f, scoreMode, scorer.twoPhaseIterator())
- : new ConstantScoreScorer(weight, 0f, scoreMode, scorer.iterator());
+ ? new ConstantScoreScorer(0f, scoreMode, scorer.twoPhaseIterator())
+ : new ConstantScoreScorer(0f, scoreMode, scorer.iterator());
}
return scorer;
}
@@ -159,7 +156,7 @@ final class BooleanScorerSupplier extends ScorerSupplier {
subs.get(Occur.MUST_NOT),
leadCost);
Scorer opt = opt(subs.get(Occur.SHOULD), minShouldMatch, scoreMode, leadCost, false);
- return new ConjunctionScorer(weight, Arrays.asList(req, opt), Arrays.asList(req, opt));
+ return new ConjunctionScorer(Arrays.asList(req, opt), Arrays.asList(req, opt));
} else {
assert scoreMode.needsScores();
return new ReqOptSumScorer(
@@ -237,7 +234,7 @@ final class BooleanScorerSupplier extends ScorerSupplier {
Scorer prohibitedScorer =
prohibited.size() == 1
? prohibited.get(0)
- : new DisjunctionSumScorer(weight, prohibited, ScoreMode.COMPLETE_NO_SCORES);
+ : new DisjunctionSumScorer(prohibited, ScoreMode.COMPLETE_NO_SCORES);
return new ReqExclBulkScorer(positiveScorer, prohibitedScorer);
}
}
@@ -349,8 +346,7 @@ final class BooleanScorerSupplier extends ScorerSupplier {
return new ConjunctionBulkScorer(requiredScoring, requiredNoScoring);
}
if (scoreMode == ScoreMode.TOP_SCORES && requiredScoring.size() > 1) {
- requiredScoring =
- Collections.singletonList(new BlockMaxConjunctionScorer(weight, requiredScoring));
+ requiredScoring = Collections.singletonList(new BlockMaxConjunctionScorer(requiredScoring));
}
Scorer conjunctionScorer;
if (requiredNoScoring.size() + requiredScoring.size() == 1) {
@@ -378,7 +374,7 @@ final class BooleanScorerSupplier extends ScorerSupplier {
List<Scorer> required = new ArrayList<>();
required.addAll(requiredScoring);
required.addAll(requiredNoScoring);
- conjunctionScorer = new ConjunctionScorer(weight, required, requiredScoring);
+ conjunctionScorer = new ConjunctionScorer(required, requiredScoring);
}
return new DefaultBulkScorer(conjunctionScorer);
}
@@ -433,14 +429,14 @@ final class BooleanScorerSupplier extends ScorerSupplier {
scoringScorers.add(scorer);
}
if (scoreMode == ScoreMode.TOP_SCORES && scoringScorers.size() > 1 && topLevelScoringClause) {
- Scorer blockMaxScorer = new BlockMaxConjunctionScorer(weight, scoringScorers);
+ Scorer blockMaxScorer = new BlockMaxConjunctionScorer(scoringScorers);
if (requiredScorers.isEmpty()) {
return blockMaxScorer;
}
scoringScorers = Collections.singletonList(blockMaxScorer);
}
requiredScorers.addAll(scoringScorers);
- return new ConjunctionScorer(weight, requiredScorers, scoringScorers);
+ return new ConjunctionScorer(requiredScorers, scoringScorers);
}
}
@@ -477,9 +473,9 @@ final class BooleanScorerSupplier extends ScorerSupplier {
// However, as WANDScorer uses more complex algorithm and data structure, we would like to
// still use DisjunctionSumScorer to handle exhaustive pure disjunctions, which may be faster
if ((scoreMode == ScoreMode.TOP_SCORES && topLevelScoringClause) || minShouldMatch > 1) {
- return new WANDScorer(weight, optionalScorers, minShouldMatch, scoreMode);
+ return new WANDScorer(optionalScorers, minShouldMatch, scoreMode);
} else {
- return new DisjunctionSumScorer(weight, optionalScorers, scoreMode);
+ return new DisjunctionSumScorer(optionalScorers, scoreMode);
}
}
}
diff --git a/lucene/core/src/java/org/apache/lucene/search/ConjunctionScorer.java b/lucene/core/src/java/org/apache/lucene/search/ConjunctionScorer.java
index 05634e5dccc..e651c95d3b3 100644
--- a/lucene/core/src/java/org/apache/lucene/search/ConjunctionScorer.java
+++ b/lucene/core/src/java/org/apache/lucene/search/ConjunctionScorer.java
@@ -31,8 +31,7 @@ class ConjunctionScorer extends Scorer {
* Create a new {@link ConjunctionScorer}, note that {@code scorers} must be a subset of {@code
* required}.
*/
- ConjunctionScorer(Weight weight, Collection<Scorer> required, Collection<Scorer> scorers) {
- super(weight);
+ ConjunctionScorer(Collection<Scorer> required, Collection<Scorer> scorers) {
assert required.containsAll(scorers);
this.disi = ConjunctionUtils.intersectScorers(required);
this.scorers = scorers.toArray(new Scorer[scorers.size()]);
diff --git a/lucene/core/src/java/org/apache/lucene/search/ConstantScoreQuery.java b/lucene/core/src/java/org/apache/lucene/search/ConstantScoreQuery.java
index 80c94a30079..cb406389f37 100644
--- a/lucene/core/src/java/org/apache/lucene/search/ConstantScoreQuery.java
+++ b/lucene/core/src/java/org/apache/lucene/search/ConstantScoreQuery.java
@@ -149,10 +149,9 @@ public final class ConstantScoreQuery extends Query {
final Scorer innerScorer = innerScorerSupplier.get(leadCost);
final TwoPhaseIterator twoPhaseIterator = innerScorer.twoPhaseIterator();
if (twoPhaseIterator == null) {
- return new ConstantScoreScorer(
- innerWeight, score(), scoreMode, innerScorer.iterator());
+ return new ConstantScoreScorer(score(), scoreMode, innerScorer.iterator());
} else {
- return new ConstantScoreScorer(innerWeight, score(), scoreMode, twoPhaseIterator);
+ return new ConstantScoreScorer(score(), scoreMode, twoPhaseIterator);
}
}
diff --git a/lucene/core/src/java/org/apache/lucene/search/ConstantScoreScorer.java b/lucene/core/src/java/org/apache/lucene/search/ConstantScoreScorer.java
index d7a3a812a51..7407edaaf54 100644
--- a/lucene/core/src/java/org/apache/lucene/search/ConstantScoreScorer.java
+++ b/lucene/core/src/java/org/apache/lucene/search/ConstantScoreScorer.java
@@ -64,14 +64,11 @@ public final class ConstantScoreScorer extends Scorer {
* Constructor based on a {@link DocIdSetIterator} which will be used to drive iteration. Two
* phase iteration will not be supported.
*
- * @param weight the parent weight
* @param score the score to return on each document
* @param scoreMode the score mode
* @param disi the iterator that defines matching documents
*/
- public ConstantScoreScorer(
- Weight weight, float score, ScoreMode scoreMode, DocIdSetIterator disi) {
- super(weight);
+ public ConstantScoreScorer(float score, ScoreMode scoreMode, DocIdSetIterator disi) {
this.score = score;
this.scoreMode = scoreMode;
// TODO: Only wrap when it is the top-level scoring clause? See
@@ -86,14 +83,11 @@ public final class ConstantScoreScorer extends Scorer {
* Constructor based on a {@link TwoPhaseIterator}. In that case the {@link Scorer} will support
* two-phase iteration.
*
- * @param weight the parent weight
* @param score the score to return on each document
* @param scoreMode the score mode
* @param twoPhaseIterator the iterator that defines matching documents
*/
- public ConstantScoreScorer(
- Weight weight, float score, ScoreMode scoreMode, TwoPhaseIterator twoPhaseIterator) {
- super(weight);
+ public ConstantScoreScorer(float score, ScoreMode scoreMode, TwoPhaseIterator twoPhaseIterator) {
this.score = score;
this.scoreMode = scoreMode;
if (scoreMode == ScoreMode.TOP_SCORES) {
diff --git a/lucene/core/src/java/org/apache/lucene/search/DisjunctionMaxQuery.java b/lucene/core/src/java/org/apache/lucene/search/DisjunctionMaxQuery.java
index 903931459fd..5a53749b667 100644
--- a/lucene/core/src/java/org/apache/lucene/search/DisjunctionMaxQuery.java
+++ b/lucene/core/src/java/org/apache/lucene/search/DisjunctionMaxQuery.java
@@ -142,7 +142,6 @@ public final class DisjunctionMaxQuery extends Query implements Iterable<Query>
} else if (scorerSuppliers.size() == 1) {
return scorerSuppliers.get(0);
} else {
- final Weight thisWeight = this;
return new ScorerSupplier() {
private long cost = -1;
@@ -153,7 +152,7 @@ public final class DisjunctionMaxQuery extends Query implements Iterable<Query>
for (ScorerSupplier ss : scorerSuppliers) {
scorers.add(ss.get(leadCost));
}
- return new DisjunctionMaxScorer(thisWeight, tieBreakerMultiplier, scorers, scoreMode);
+ return new DisjunctionMaxScorer(tieBreakerMultiplier, scorers, scoreMode);
}
@Override
diff --git a/lucene/core/src/java/org/apache/lucene/search/DisjunctionMaxScorer.java b/lucene/core/src/java/org/apache/lucene/search/DisjunctionMaxScorer.java
index a43077a725e..c12a131fc5e 100644
--- a/lucene/core/src/java/org/apache/lucene/search/DisjunctionMaxScorer.java
+++ b/lucene/core/src/java/org/apache/lucene/search/DisjunctionMaxScorer.java
@@ -36,15 +36,13 @@ final class DisjunctionMaxScorer extends DisjunctionScorer {
/**
* Creates a new instance of DisjunctionMaxScorer
*
- * @param weight The Weight to be used.
* @param tieBreakerMultiplier Multiplier applied to non-maximum-scoring subqueries for a document
* as they are summed into the result.
* @param subScorers The sub scorers this Scorer should iterate on
*/
- DisjunctionMaxScorer(
- Weight weight, float tieBreakerMultiplier, List<Scorer> subScorers, ScoreMode scoreMode)
+ DisjunctionMaxScorer(float tieBreakerMultiplier, List<Scorer> subScorers, ScoreMode scoreMode)
throws IOException {
- super(weight, subScorers, scoreMode);
+ super(subScorers, scoreMode);
this.subScorers = subScorers;
this.tieBreakerMultiplier = tieBreakerMultiplier;
if (tieBreakerMultiplier < 0 || tieBreakerMultiplier > 1) {
diff --git a/lucene/core/src/java/org/apache/lucene/search/DisjunctionScorer.java b/lucene/core/src/java/org/apache/lucene/search/DisjunctionScorer.java
index 74fb42f01b3..8b4da6ffed7 100644
--- a/lucene/core/src/java/org/apache/lucene/search/DisjunctionScorer.java
+++ b/lucene/core/src/java/org/apache/lucene/search/DisjunctionScorer.java
@@ -31,9 +31,7 @@ abstract class DisjunctionScorer extends Scorer {
private final DocIdSetIterator approximation;
private final TwoPhase twoPhase;
- protected DisjunctionScorer(Weight weight, List<Scorer> subScorers, ScoreMode scoreMode)
- throws IOException {
- super(weight);
+ protected DisjunctionScorer(List<Scorer> subScorers, ScoreMode scoreMode) throws IOException {
if (subScorers.size() <= 1) {
throw new IllegalArgumentException("There must be at least 2 subScorers");
}
diff --git a/lucene/core/src/java/org/apache/lucene/search/DisjunctionSumScorer.java b/lucene/core/src/java/org/apache/lucene/search/DisjunctionSumScorer.java
index 26fbd19bcd6..3b5b98378c8 100644
--- a/lucene/core/src/java/org/apache/lucene/search/DisjunctionSumScorer.java
+++ b/lucene/core/src/java/org/apache/lucene/search/DisjunctionSumScorer.java
@@ -28,12 +28,10 @@ final class DisjunctionSumScorer extends DisjunctionScorer {
/**
* Construct a <code>DisjunctionScorer</code>.
*
- * @param weight The weight to be used.
* @param subScorers Array of at least two subscorers.
*/
- DisjunctionSumScorer(Weight weight, List<Scorer> subScorers, ScoreMode scoreMode)
- throws IOException {
- super(weight, subScorers, scoreMode);
+ DisjunctionSumScorer(List<Scorer> subScorers, ScoreMode scoreMode) throws IOException {
+ super(subScorers, scoreMode);
this.scorers = subScorers;
}
diff --git a/lucene/core/src/java/org/apache/lucene/search/DocValuesRewriteMethod.java b/lucene/core/src/java/org/apache/lucene/search/DocValuesRewriteMethod.java
index 93e59435a9a..ce179cf85d2 100644
--- a/lucene/core/src/java/org/apache/lucene/search/DocValuesRewriteMethod.java
+++ b/lucene/core/src/java/org/apache/lucene/search/DocValuesRewriteMethod.java
@@ -153,7 +153,6 @@ public final class DocValuesRewriteMethod extends MultiTermQuery.RewriteMethod {
return null; // no values/docs so nothing can match
}
- final Weight weight = this;
return new ScorerSupplier() {
@Override
public Scorer get(long leadCost) throws IOException {
@@ -164,8 +163,7 @@ public final class DocValuesRewriteMethod extends MultiTermQuery.RewriteMethod {
if (termsEnum.next() == null) {
// no matching terms
- return new ConstantScoreScorer(
- weight, score(), scoreMode, DocIdSetIterator.empty());
+ return new ConstantScoreScorer(score(), scoreMode, DocIdSetIterator.empty());
}
// Create a bit set for the "term set" ordinals (these are the terms provided by the
@@ -184,8 +182,7 @@ public final class DocValuesRewriteMethod extends MultiTermQuery.RewriteMethod {
// no terms matched in this segment
if (maxOrd < 0) {
- return new ConstantScoreScorer(
- weight, score(), scoreMode, DocIdSetIterator.empty());
+ return new ConstantScoreScorer(score(), scoreMode, DocIdSetIterator.empty());
}
final SortedDocValues singleton = DocValues.unwrapSingleton(values);
@@ -227,7 +224,7 @@ public final class DocValuesRewriteMethod extends MultiTermQuery.RewriteMethod {
};
}
- return new ConstantScoreScorer(weight, score(), scoreMode, iterator);
+ return new ConstantScoreScorer(score(), scoreMode, iterator);
}
@Override
diff --git a/lucene/core/src/java/org/apache/lucene/search/FieldExistsQuery.java b/lucene/core/src/java/org/apache/lucene/search/FieldExistsQuery.java
index 3aa231d21d9..409bcbc0b64 100644
--- a/lucene/core/src/java/org/apache/lucene/search/FieldExistsQuery.java
+++ b/lucene/core/src/java/org/apache/lucene/search/FieldExistsQuery.java
@@ -213,7 +213,7 @@ public class FieldExistsQuery extends Query {
if (iterator == null) {
return null;
}
- final var scorer = new ConstantScoreScorer(this, score(), scoreMode, iterator);
+ final var scorer = new ConstantScoreScorer(score(), scoreMode, iterator);
return new DefaultScorerSupplier(scorer);
}
diff --git a/lucene/core/src/java/org/apache/lucene/search/FilterScorer.java b/lucene/core/src/java/org/apache/lucene/search/FilterScorer.java
index 337531dbb32..9ea6fad407e 100644
--- a/lucene/core/src/java/org/apache/lucene/search/FilterScorer.java
+++ b/lucene/core/src/java/org/apache/lucene/search/FilterScorer.java
@@ -29,24 +29,12 @@ import org.apache.lucene.util.Unwrappable;
public abstract class FilterScorer extends Scorer implements Unwrappable<Scorer> {
protected final Scorer in;
- /**
- * Create a new FilterScorer
- *
- * @param in the {@link Scorer} to wrap
- */
- public FilterScorer(Scorer in) {
- super(in.weight);
- this.in = in;
- }
-
/**
* Create a new FilterScorer with a specific weight
*
* @param in the {@link Scorer} to wrap
- * @param weight a {@link Weight}
*/
- public FilterScorer(Scorer in, Weight weight) {
- super(weight);
+ public FilterScorer(Scorer in) {
if (in == null) {
throw new NullPointerException("wrapped Scorer must not be null");
}
diff --git a/lucene/core/src/java/org/apache/lucene/search/IndexSortSortedNumericDocValuesRangeQuery.java b/lucene/core/src/java/org/apache/lucene/search/IndexSortSortedNumericDocValuesRangeQuery.java
index aead6d9f9b8..0c27e4de83f 100644
--- a/lucene/core/src/java/org/apache/lucene/search/IndexSortSortedNumericDocValuesRangeQuery.java
+++ b/lucene/core/src/java/org/apache/lucene/search/IndexSortSortedNumericDocValuesRangeQuery.java
@@ -158,14 +158,13 @@ public class IndexSortSortedNumericDocValuesRangeQuery extends Query {
@Override
public ScorerSupplier scorerSupplier(LeafReaderContext context) throws IOException {
- final Weight weight = this;
IteratorAndCount itAndCount = getDocIdSetIteratorOrNull(context);
if (itAndCount != null) {
DocIdSetIterator disi = itAndCount.it;
return new ScorerSupplier() {
@Override
public Scorer get(long leadCost) throws IOException {
- return new ConstantScoreScorer(weight, score(), scoreMode, disi);
+ return new ConstantScoreScorer(score(), scoreMode, disi);
}
@Override
diff --git a/lucene/core/src/java/org/apache/lucene/search/IndriAndScorer.java b/lucene/core/src/java/org/apache/lucene/search/IndriAndScorer.java
index 28c33db94a5..72cc2ff530a 100644
--- a/lucene/core/src/java/org/apache/lucene/search/IndriAndScorer.java
+++ b/lucene/core/src/java/org/apache/lucene/search/IndriAndScorer.java
@@ -25,9 +25,9 @@ import java.util.List;
*/
public class IndriAndScorer extends IndriDisjunctionScorer {
- protected IndriAndScorer(Weight weight, List<Scorer> subScorers, ScoreMode scoreMode, float boost)
+ protected IndriAndScorer(List<Scorer> subScorers, ScoreMode scoreMode, float boost)
throws IOException {
- super(weight, subScorers, scoreMode, boost);
+ super(subScorers, scoreMode, boost);
}
@Override
diff --git a/lucene/core/src/java/org/apache/lucene/search/IndriAndWeight.java b/lucene/core/src/java/org/apache/lucene/search/IndriAndWeight.java
index 58938be4333..1aa9db7c159 100644
--- a/lucene/core/src/java/org/apache/lucene/search/IndriAndWeight.java
+++ b/lucene/core/src/java/org/apache/lucene/search/IndriAndWeight.java
@@ -59,7 +59,7 @@ public class IndriAndWeight extends Weight {
}
Scorer scorer = subScorers.get(0);
if (subScorers.size() > 1) {
- scorer = new IndriAndScorer(this, subScorers, scoreMode, boost);
+ scorer = new IndriAndScorer(subScorers, scoreMode, boost);
}
return scorer;
}
diff --git a/lucene/core/src/java/org/apache/lucene/search/IndriDisjunctionScorer.java b/lucene/core/src/java/org/apache/lucene/search/IndriDisjunctionScorer.java
index 1cfab609b1f..e501013f4ab 100644
--- a/lucene/core/src/java/org/apache/lucene/search/IndriDisjunctionScorer.java
+++ b/lucene/core/src/java/org/apache/lucene/search/IndriDisjunctionScorer.java
@@ -30,9 +30,8 @@ public abstract class IndriDisjunctionScorer extends IndriScorer {
private final DisiPriorityQueue subScorers;
private final DocIdSetIterator approximation;
- protected IndriDisjunctionScorer(
- Weight weight, List<Scorer> subScorersList, ScoreMode scoreMode, float boost) {
- super(weight, boost);
+ protected IndriDisjunctionScorer(List<Scorer> subScorersList, ScoreMode scoreMode, float boost) {
+ super(boost);
this.subScorersList = subScorersList;
this.subScorers = new DisiPriorityQueue(subScorersList.size());
for (Scorer scorer : subScorersList) {
diff --git a/lucene/core/src/java/org/apache/lucene/search/IndriScorer.java b/lucene/core/src/java/org/apache/lucene/search/IndriScorer.java
index 7d7902d1604..1dd97dbf7a0 100644
--- a/lucene/core/src/java/org/apache/lucene/search/IndriScorer.java
+++ b/lucene/core/src/java/org/apache/lucene/search/IndriScorer.java
@@ -26,8 +26,7 @@ public abstract class IndriScorer extends Scorer {
private float boost;
- protected IndriScorer(Weight weight, float boost) {
- super(weight);
+ protected IndriScorer(float boost) {
this.boost = boost;
}
diff --git a/lucene/core/src/java/org/apache/lucene/search/LRUQueryCache.java b/lucene/core/src/java/org/apache/lucene/search/LRUQueryCache.java
index 1bbafc1908d..7f82e78e056 100644
--- a/lucene/core/src/java/org/apache/lucene/search/LRUQueryCache.java
+++ b/lucene/core/src/java/org/apache/lucene/search/LRUQueryCache.java
@@ -779,8 +779,7 @@ public class LRUQueryCache implements QueryCache, Accountable {
disi = DocIdSetIterator.empty();
}
- return new ConstantScoreScorer(
- CachingWrapperWeight.this, 0f, ScoreMode.COMPLETE_NO_SCORES, disi);
+ return new ConstantScoreScorer(0f, ScoreMode.COMPLETE_NO_SCORES, disi);
}
@Override
@@ -805,8 +804,7 @@ public class LRUQueryCache implements QueryCache, Accountable {
return new ScorerSupplier() {
@Override
public Scorer get(long LeadCost) throws IOException {
- return new ConstantScoreScorer(
- CachingWrapperWeight.this, 0f, ScoreMode.COMPLETE_NO_SCORES, disi);
+ return new ConstantScoreScorer(0f, ScoreMode.COMPLETE_NO_SCORES, disi);
}
@Override
diff --git a/lucene/core/src/java/org/apache/lucene/search/MatchAllDocsQuery.java b/lucene/core/src/java/org/apache/lucene/search/MatchAllDocsQuery.java
index 426fc7c2ff5..8bed66a7f49 100644
--- a/lucene/core/src/java/org/apache/lucene/search/MatchAllDocsQuery.java
+++ b/lucene/core/src/java/org/apache/lucene/search/MatchAllDocsQuery.java
@@ -33,13 +33,12 @@ public final class MatchAllDocsQuery extends Query {
@Override
public ScorerSupplier scorerSupplier(LeafReaderContext context) throws IOException {
- final Weight weight = this;
return new ScorerSupplier() {
@Override
public Scorer get(long leadCost) throws IOException {
return new ConstantScoreScorer(
- weight, score(), scoreMode, DocIdSetIterator.all(context.reader().maxDoc()));
+ score(), scoreMode, DocIdSetIterator.all(context.reader().maxDoc()));
}
@Override
diff --git a/lucene/core/src/java/org/apache/lucene/search/MultiTermQueryConstantScoreBlendedWrapper.java b/lucene/core/src/java/org/apache/lucene/search/MultiTermQueryConstantScoreBlendedWrapper.java
index a598f644d0c..c108f6d9c1c 100644
--- a/lucene/core/src/java/org/apache/lucene/search/MultiTermQueryConstantScoreBlendedWrapper.java
+++ b/lucene/core/src/java/org/apache/lucene/search/MultiTermQueryConstantScoreBlendedWrapper.java
@@ -132,6 +132,6 @@ final class MultiTermQueryConstantScoreBlendedWrapper<Q extends MultiTermQuery>
private static Scorer wrapWithDummyScorer(Weight weight, DocIdSetIterator disi) {
// The score and score mode do not actually matter here, except that using TOP_SCORES results
// in another wrapper object getting created around the disi, so we try to avoid that:
- return new ConstantScoreScorer(weight, 1f, ScoreMode.COMPLETE_NO_SCORES, disi);
+ return new ConstantScoreScorer(1f, ScoreMode.COMPLETE_NO_SCORES, disi);
}
}
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 4925de479f8..26a1387acda 100644
--- a/lucene/core/src/java/org/apache/lucene/search/PhraseScorer.java
+++ b/lucene/core/src/java/org/apache/lucene/search/PhraseScorer.java
@@ -32,8 +32,7 @@ class PhraseScorer extends Scorer {
private float minCompetitiveScore = 0;
private float freq = 0;
- PhraseScorer(Weight weight, PhraseMatcher matcher, ScoreMode scoreMode, LeafSimScorer simScorer) {
- super(weight);
+ PhraseScorer(PhraseMatcher matcher, ScoreMode scoreMode, LeafSimScorer simScorer) {
this.matcher = matcher;
this.scoreMode = scoreMode;
this.simScorer = simScorer;
@@ -103,9 +102,4 @@ class PhraseScorer extends Scorer {
public float getMaxScore(int upTo) throws IOException {
return maxScoreCache.getMaxScore(upTo);
}
-
- @Override
- public String toString() {
- return "PhraseScorer(" + weight + ")";
- }
}
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 b88ee763543..6aa1d684968 100644
--- a/lucene/core/src/java/org/apache/lucene/search/PhraseWeight.java
+++ b/lucene/core/src/java/org/apache/lucene/search/PhraseWeight.java
@@ -65,7 +65,7 @@ public abstract class PhraseWeight extends Weight {
if (matcher == null) return null;
LeafSimScorer simScorer =
new LeafSimScorer(stats, context.reader(), field, scoreMode.needsScores());
- final var scorer = new PhraseScorer(this, matcher, scoreMode, simScorer);
+ final var scorer = new PhraseScorer(matcher, scoreMode, simScorer);
return new DefaultScorerSupplier(scorer);
}
diff --git a/lucene/core/src/java/org/apache/lucene/search/PointInSetQuery.java b/lucene/core/src/java/org/apache/lucene/search/PointInSetQuery.java
index cc6047916fb..c2efa68a45b 100644
--- a/lucene/core/src/java/org/apache/lucene/search/PointInSetQuery.java
+++ b/lucene/core/src/java/org/apache/lucene/search/PointInSetQuery.java
@@ -145,7 +145,6 @@ public abstract class PointInSetQuery extends Query implements Accountable {
return new ConstantScoreWeight(this, boost) {
@Override
public ScorerSupplier scorerSupplier(LeafReaderContext context) throws IOException {
- final Weight weight = this;
LeafReader reader = context.reader();
PointValues values = reader.getPointValues(field);
@@ -184,7 +183,7 @@ public abstract class PointInSetQuery extends Query implements Accountable {
DocIdSetBuilder result = new DocIdSetBuilder(reader.maxDoc(), values, field);
values.intersect(new MergePointVisitor(sortedPackedPoints, result));
DocIdSetIterator iterator = result.build().iterator();
- return new ConstantScoreScorer(weight, score(), scoreMode, iterator);
+ return new ConstantScoreScorer(score(), scoreMode, iterator);
}
@Override
@@ -221,7 +220,7 @@ public abstract class PointInSetQuery extends Query implements Accountable {
visitor.setPoint(point);
values.intersect(visitor);
}
- return new ConstantScoreScorer(weight, score(), scoreMode, result.build().iterator());
+ return new ConstantScoreScorer(score(), scoreMode, result.build().iterator());
}
@Override
diff --git a/lucene/core/src/java/org/apache/lucene/search/PointRangeQuery.java b/lucene/core/src/java/org/apache/lucene/search/PointRangeQuery.java
index 5d2a00f0512..bfcef92f6f6 100644
--- a/lucene/core/src/java/org/apache/lucene/search/PointRangeQuery.java
+++ b/lucene/core/src/java/org/apache/lucene/search/PointRangeQuery.java
@@ -341,14 +341,13 @@ public abstract class PointRangeQuery extends Query {
allDocsMatch = false;
}
- final Weight weight = this;
if (allDocsMatch) {
// all docs have a value and all points are within bounds, so everything matches
return new ScorerSupplier() {
@Override
public Scorer get(long leadCost) {
return new ConstantScoreScorer(
- weight, score(), scoreMode, DocIdSetIterator.all(reader.maxDoc()));
+ score(), scoreMode, DocIdSetIterator.all(reader.maxDoc()));
}
@Override
@@ -376,12 +375,12 @@ public abstract class PointRangeQuery extends Query {
long[] cost = new long[] {reader.maxDoc()};
values.intersect(getInverseIntersectVisitor(result, cost));
final DocIdSetIterator iterator = new BitSetIterator(result, cost[0]);
- return new ConstantScoreScorer(weight, score(), scoreMode, iterator);
+ return new ConstantScoreScorer(score(), scoreMode, iterator);
}
values.intersect(visitor);
DocIdSetIterator iterator = result.build().iterator();
- return new ConstantScoreScorer(weight, score(), scoreMode, iterator);
+ return new ConstantScoreScorer(score(), scoreMode, iterator);
}
@Override
diff --git a/lucene/core/src/java/org/apache/lucene/search/ReqExclScorer.java b/lucene/core/src/java/org/apache/lucene/search/ReqExclScorer.java
index 9a87ba3f727..914a1e56724 100644
--- a/lucene/core/src/java/org/apache/lucene/search/ReqExclScorer.java
+++ b/lucene/core/src/java/org/apache/lucene/search/ReqExclScorer.java
@@ -40,7 +40,6 @@ class ReqExclScorer extends Scorer {
* @param exclScorer indicates exclusion.
*/
public ReqExclScorer(Scorer reqScorer, Scorer exclScorer) {
- super(reqScorer.weight);
this.reqScorer = reqScorer;
reqTwoPhaseIterator = reqScorer.twoPhaseIterator();
if (reqTwoPhaseIterator == null) {
diff --git a/lucene/core/src/java/org/apache/lucene/search/ReqOptSumScorer.java b/lucene/core/src/java/org/apache/lucene/search/ReqOptSumScorer.java
index 091323d510b..3e86af3aa8f 100644
--- a/lucene/core/src/java/org/apache/lucene/search/ReqOptSumScorer.java
+++ b/lucene/core/src/java/org/apache/lucene/search/ReqOptSumScorer.java
@@ -48,7 +48,6 @@ class ReqOptSumScorer extends Scorer {
*/
public ReqOptSumScorer(Scorer reqScorer, Scorer optScorer, ScoreMode scoreMode)
throws IOException {
- super(reqScorer.weight);
assert reqScorer != null;
assert optScorer != null;
this.reqScorer = reqScorer;
diff --git a/lucene/core/src/java/org/apache/lucene/search/Scorer.java b/lucene/core/src/java/org/apache/lucene/search/Scorer.java
index 7f613afe9e4..7da2420207e 100644
--- a/lucene/core/src/java/org/apache/lucene/search/Scorer.java
+++ b/lucene/core/src/java/org/apache/lucene/search/Scorer.java
@@ -17,7 +17,6 @@
package org.apache.lucene.search;
import java.io.IOException;
-import java.util.Objects;
/**
* Expert: Common scoring functionality for different types of queries.
@@ -27,27 +26,6 @@ import java.util.Objects;
*/
public abstract class Scorer extends Scorable {
- /** the Scorer's parent Weight */
- protected final Weight weight;
-
- /**
- * Constructs a Scorer
- *
- * @param weight The scorers <code>Weight</code>.
- */
- protected Scorer(Weight weight) {
- this.weight = Objects.requireNonNull(weight);
- }
-
- /**
- * returns parent Weight
- *
- * @lucene.experimental
- */
- public Weight getWeight() {
- return weight;
- }
-
/** Returns the doc ID that is currently being scored. */
public abstract int docID();
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 e36619dacb1..0500f4630dc 100644
--- a/lucene/core/src/java/org/apache/lucene/search/SynonymQuery.java
+++ b/lucene/core/src/java/org/apache/lucene/search/SynonymQuery.java
@@ -309,9 +309,9 @@ public final class SynonymQuery extends Query {
if (iterators.size() == 1) {
final TermScorer scorer;
if (scoreMode == ScoreMode.TOP_SCORES) {
- scorer = new TermScorer(this, impacts.get(0), simScorer);
+ scorer = new TermScorer(impacts.get(0), simScorer);
} else {
- scorer = new TermScorer(this, iterators.get(0), simScorer);
+ scorer = new TermScorer(iterators.get(0), simScorer);
}
float boost = termBoosts.get(0);
synonymScorer =
@@ -324,7 +324,7 @@ public final class SynonymQuery extends Query {
DisiPriorityQueue queue = new DisiPriorityQueue(iterators.size());
for (int i = 0; i < iterators.size(); i++) {
PostingsEnum postings = iterators.get(i);
- final TermScorer termScorer = new TermScorer(this, postings, simScorer);
+ final TermScorer termScorer = new TermScorer(postings, simScorer);
float boost = termBoosts.get(i);
final DisiWrapperFreq wrapper = new DisiWrapperFreq(termScorer, boost);
queue.add(wrapper);
@@ -348,7 +348,7 @@ public final class SynonymQuery extends Query {
iterator = impactsDisi;
}
- synonymScorer = new SynonymScorer(this, queue, iterator, impactsDisi, simScorer);
+ synonymScorer = new SynonymScorer(queue, iterator, impactsDisi, simScorer);
}
return new DefaultScorerSupplier(synonymScorer);
}
@@ -536,12 +536,10 @@ public final class SynonymQuery extends Query {
private final LeafSimScorer simScorer;
SynonymScorer(
- Weight weight,
DisiPriorityQueue queue,
DocIdSetIterator iterator,
ImpactsDISI impactsDisi,
LeafSimScorer simScorer) {
- super(weight);
this.queue = queue;
this.iterator = iterator;
this.maxScoreCache = impactsDisi.getMaxScoreCache();
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 8f5de54c7e9..84037acd0d4 100644
--- a/lucene/core/src/java/org/apache/lucene/search/TermQuery.java
+++ b/lucene/core/src/java/org/apache/lucene/search/TermQuery.java
@@ -141,7 +141,6 @@ public class TermQuery extends Query {
topLevelScoringClause);
} else {
return new TermScorer(
- TermWeight.this,
termsEnum.postings(
null, scoreMode.needsScores() ? PostingsEnum.FREQS : PostingsEnum.NONE),
scorer);
diff --git a/lucene/core/src/java/org/apache/lucene/search/TermScorer.java b/lucene/core/src/java/org/apache/lucene/search/TermScorer.java
index 12d59db76a3..22c6102b958 100644
--- a/lucene/core/src/java/org/apache/lucene/search/TermScorer.java
+++ b/lucene/core/src/java/org/apache/lucene/search/TermScorer.java
@@ -34,8 +34,7 @@ public final class TermScorer extends Scorer {
private final MaxScoreCache maxScoreCache;
/** Construct a {@link TermScorer} that will iterate all documents. */
- public TermScorer(Weight weight, PostingsEnum postingsEnum, LeafSimScorer docScorer) {
- super(weight);
+ public TermScorer(PostingsEnum postingsEnum, LeafSimScorer docScorer) {
iterator = this.postingsEnum = postingsEnum;
ImpactsEnum impactsEnum = new SlowImpactsEnum(postingsEnum);
maxScoreCache = new MaxScoreCache(impactsEnum, docScorer.getSimScorer());
@@ -52,7 +51,6 @@ public final class TermScorer extends Scorer {
ImpactsEnum impactsEnum,
LeafSimScorer docScorer,
boolean topLevelScoringClause) {
- super(weight);
postingsEnum = impactsEnum;
maxScoreCache = new MaxScoreCache(impactsEnum, docScorer.getSimScorer());
if (topLevelScoringClause) {
@@ -107,10 +105,4 @@ public final class TermScorer extends Scorer {
impactsDisi.setMinCompetitiveScore(minScore);
}
}
-
- /** Returns a string representation of this <code>TermScorer</code>. */
- @Override
- public String toString() {
- return "scorer(" + weight + ")[" + super.toString() + "]";
- }
}
diff --git a/lucene/core/src/java/org/apache/lucene/search/WANDScorer.java b/lucene/core/src/java/org/apache/lucene/search/WANDScorer.java
index d33d3a00d37..fe5e8803b4c 100644
--- a/lucene/core/src/java/org/apache/lucene/search/WANDScorer.java
+++ b/lucene/core/src/java/org/apache/lucene/search/WANDScorer.java
@@ -150,9 +150,8 @@ final class WANDScorer extends Scorer {
final ScoreMode scoreMode;
- WANDScorer(Weight weight, Collection<Scorer> scorers, int minShouldMatch, ScoreMode scoreMode)
+ WANDScorer(Collection<Scorer> scorers, int minShouldMatch, ScoreMode scoreMode)
throws IOException {
- super(weight);
if (minShouldMatch >= scorers.size()) {
throw new IllegalArgumentException("minShouldMatch should be < the number of scorers");
diff --git a/lucene/core/src/test/org/apache/lucene/search/BaseKnnVectorQueryTestCase.java b/lucene/core/src/test/org/apache/lucene/search/BaseKnnVectorQueryTestCase.java
index fd61a34dd58..7520003ab4f 100644
--- a/lucene/core/src/test/org/apache/lucene/search/BaseKnnVectorQueryTestCase.java
+++ b/lucene/core/src/test/org/apache/lucene/search/BaseKnnVectorQueryTestCase.java
@@ -1046,7 +1046,7 @@ abstract class BaseKnnVectorQueryTestCase extends LuceneTestCase {
throw new UnsupportedOperationException("reusing BitSet is not supported");
}
};
- final var scorer = new ConstantScoreScorer(this, score(), scoreMode, bitSetIterator);
+ final var scorer = new ConstantScoreScorer(score(), scoreMode, bitSetIterator);
return new DefaultScorerSupplier(scorer);
}
diff --git a/lucene/core/src/test/org/apache/lucene/search/JustCompileSearch.java b/lucene/core/src/test/org/apache/lucene/search/JustCompileSearch.java
index adfc4cab5ca..df30c5ee005 100644
--- a/lucene/core/src/test/org/apache/lucene/search/JustCompileSearch.java
+++ b/lucene/core/src/test/org/apache/lucene/search/JustCompileSearch.java
@@ -164,11 +164,6 @@ final class JustCompileSearch {
}
static final class JustCompileScorer extends Scorer {
-
- protected JustCompileScorer(Weight weight) {
- super(weight);
- }
-
@Override
public float score() {
throw new UnsupportedOperationException(UNSUPPORTED_MSG);
diff --git a/lucene/core/src/test/org/apache/lucene/search/TestBoolean2ScorerSupplier.java b/lucene/core/src/test/org/apache/lucene/search/TestBoolean2ScorerSupplier.java
index 58cd8a652bd..780b6ea5681 100644
--- a/lucene/core/src/test/org/apache/lucene/search/TestBoolean2ScorerSupplier.java
+++ b/lucene/core/src/test/org/apache/lucene/search/TestBoolean2ScorerSupplier.java
@@ -57,7 +57,6 @@ public class TestBoolean2ScorerSupplier extends LuceneTestCase {
private final DocIdSetIterator it;
FakeScorer(long cost) {
- super(new FakeWeight());
this.it = DocIdSetIterator.all(Math.toIntExact(cost));
}
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 cfdc9257438..68c4c6f8f19 100644
--- a/lucene/core/src/test/org/apache/lucene/search/TestBooleanQueryVisitSubscorers.java
+++ b/lucene/core/src/test/org/apache/lucene/search/TestBooleanQueryVisitSubscorers.java
@@ -256,9 +256,9 @@ public class TestBooleanQueryVisitSubscorers extends LuceneTestCase {
"ConjunctionScorer\n"
+ " MUST ConstantScoreScorer\n"
+ " MUST WANDScorer\n"
- + " SHOULD TermScorer body:crawler\n"
- + " SHOULD TermScorer body:web\n"
- + " SHOULD TermScorer body:nutch",
+ + " SHOULD TermScorer\n"
+ + " SHOULD TermScorer\n"
+ + " SHOULD TermScorer",
summary);
}
}
@@ -272,7 +272,7 @@ public class TestBooleanQueryVisitSubscorers extends LuceneTestCase {
assertEquals(1, scoreSummary.numHits.get());
assertFalse(scoreSummary.summaries.isEmpty());
for (String summary : scoreSummary.summaries) {
- assertEquals("TermScorer body:nutch", summary);
+ assertEquals("TermScorer", summary);
}
}
@@ -329,14 +329,6 @@ public class TestBooleanQueryVisitSubscorers extends LuceneTestCase {
private static void summarizeScorer(
final StringBuilder builder, final Scorable scorer, final int indent) throws IOException {
builder.append(scorer.getClass().getSimpleName());
- if (scorer instanceof TermScorer) {
- TermQuery termQuery = (TermQuery) ((Scorer) scorer).getWeight().getQuery();
- builder
- .append(" ")
- .append(termQuery.getTerm().field())
- .append(":")
- .append(termQuery.getTerm().text());
- }
for (final Scorable.ChildScorable childScorer : scorer.getChildren()) {
indent(builder, indent + 1).append(childScorer.relationship).append(" ");
summarizeScorer(builder, childScorer.child, indent + 2);
diff --git a/lucene/core/src/test/org/apache/lucene/search/TestConjunctionDISI.java b/lucene/core/src/test/org/apache/lucene/search/TestConjunctionDISI.java
index ae896ee41cc..68d4263b9f4 100644
--- a/lucene/core/src/test/org/apache/lucene/search/TestConjunctionDISI.java
+++ b/lucene/core/src/test/org/apache/lucene/search/TestConjunctionDISI.java
@@ -23,7 +23,6 @@ import java.util.Arrays;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
-import org.apache.lucene.index.LeafReaderContext;
import org.apache.lucene.tests.util.LuceneTestCase;
import org.apache.lucene.tests.util.TestUtil;
import org.apache.lucene.util.BitDocIdSet;
@@ -86,28 +85,6 @@ public class TestConjunctionDISI extends LuceneTestCase {
return scorer(TwoPhaseIterator.asDocIdSetIterator(twoPhaseIterator), twoPhaseIterator);
}
- private static class FakeWeight extends Weight {
-
- protected FakeWeight() {
- super(new MatchNoDocsQuery());
- }
-
- @Override
- public Explanation explain(LeafReaderContext context, int doc) throws IOException {
- return null;
- }
-
- @Override
- public ScorerSupplier scorerSupplier(LeafReaderContext context) throws IOException {
- return null;
- }
-
- @Override
- public boolean isCacheable(LeafReaderContext ctx) {
- return false;
- }
- }
-
/**
* Create a {@link Scorer} that wraps the given {@link DocIdSetIterator}. It also accepts a {@link
* TwoPhaseIterator} view, which is exposed in {@link Scorer#twoPhaseIterator()}. When the
@@ -116,7 +93,7 @@ public class TestConjunctionDISI extends LuceneTestCase {
* ConjunctionDISI} takes advantage of the {@link TwoPhaseIterator} view.
*/
private static Scorer scorer(DocIdSetIterator it, TwoPhaseIterator twoPhaseIterator) {
- return new Scorer(new FakeWeight()) {
+ return new Scorer() {
@Override
public DocIdSetIterator iterator() {
@@ -237,17 +214,13 @@ public class TestConjunctionDISI extends LuceneTestCase {
sets[i] = set;
iterators[i] =
new ConstantScoreScorer(
- new FakeWeight(),
- 0f,
- ScoreMode.TOP_SCORES,
- anonymizeIterator(new BitDocIdSet(set).iterator()));
+ 0f, ScoreMode.TOP_SCORES, anonymizeIterator(new BitDocIdSet(set).iterator()));
break;
case 1:
// bitSet iterator
sets[i] = set;
iterators[i] =
- new ConstantScoreScorer(
- new FakeWeight(), 0f, ScoreMode.TOP_SCORES, new BitDocIdSet(set).iterator());
+ new ConstantScoreScorer(0f, ScoreMode.TOP_SCORES, new BitDocIdSet(set).iterator());
break;
default:
// scorer with approximation
@@ -282,10 +255,7 @@ public class TestConjunctionDISI extends LuceneTestCase {
sets[i] = set;
iterators[i] =
new ConstantScoreScorer(
- new FakeWeight(),
- 0f,
- ScoreMode.COMPLETE_NO_SCORES,
- new BitDocIdSet(set).iterator());
+ 0f, ScoreMode.COMPLETE_NO_SCORES, new BitDocIdSet(set).iterator());
} else {
// scorer with approximation
final FixedBitSet confirmed = clearRandomBits(set);
@@ -328,17 +298,13 @@ public class TestConjunctionDISI extends LuceneTestCase {
sets[i] = set;
newIterator =
new ConstantScoreScorer(
- new FakeWeight(),
- 0f,
- ScoreMode.TOP_SCORES,
- anonymizeIterator(new BitDocIdSet(set).iterator()));
+ 0f, ScoreMode.TOP_SCORES, anonymizeIterator(new BitDocIdSet(set).iterator()));
break;
case 1:
// bitSet iterator
sets[i] = set;
newIterator =
- new ConstantScoreScorer(
- new FakeWeight(), 0f, ScoreMode.TOP_SCORES, new BitDocIdSet(set).iterator());
+ new ConstantScoreScorer(0f, ScoreMode.TOP_SCORES, new BitDocIdSet(set).iterator());
break;
default:
// scorer with approximation
@@ -384,8 +350,7 @@ public class TestConjunctionDISI extends LuceneTestCase {
// simple iterator
sets[i] = set;
scorers.add(
- new ConstantScoreScorer(
- new FakeWeight(), 0f, ScoreMode.TOP_SCORES, new BitDocIdSet(set).iterator()));
+ new ConstantScoreScorer(0f, ScoreMode.TOP_SCORES, new BitDocIdSet(set).iterator()));
} else {
// scorer with approximation
final FixedBitSet confirmed = clearRandomBits(set);
@@ -404,15 +369,11 @@ public class TestConjunctionDISI extends LuceneTestCase {
List<Scorer> subIterators = scorers.subList(subSeqStart, subSeqEnd);
Scorer subConjunction;
if (wrapWithScorer) {
- subConjunction =
- new ConjunctionScorer(new FakeWeight(), subIterators, Collections.emptyList());
+ subConjunction = new ConjunctionScorer(subIterators, Collections.emptyList());
} else {
subConjunction =
new ConstantScoreScorer(
- new FakeWeight(),
- 0f,
- ScoreMode.TOP_SCORES,
- ConjunctionUtils.intersectScorers(subIterators));
+ 0f, ScoreMode.TOP_SCORES, ConjunctionUtils.intersectScorers(subIterators));
}
scorers.set(subSeqStart, subConjunction);
int toRemove = subSeqEnd - subSeqStart - 1;
@@ -423,8 +384,7 @@ public class TestConjunctionDISI extends LuceneTestCase {
if (scorers.size() == 1) {
// ConjunctionDISI needs two iterators
scorers.add(
- new ConstantScoreScorer(
- new FakeWeight(), 0f, ScoreMode.TOP_SCORES, DocIdSetIterator.all(maxDoc)));
+ new ConstantScoreScorer(0f, ScoreMode.TOP_SCORES, DocIdSetIterator.all(maxDoc)));
}
final DocIdSetIterator conjunction = ConjunctionUtils.intersectScorers(scorers);
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 c491fe6c47f..675aa959b66 100644
--- a/lucene/core/src/test/org/apache/lucene/search/TestConjunctions.java
+++ b/lucene/core/src/test/org/apache/lucene/search/TestConjunctions.java
@@ -19,6 +19,7 @@ package org.apache.lucene.search;
import java.io.IOException;
import java.util.Collection;
import java.util.HashSet;
+import java.util.List;
import java.util.Set;
import java.util.concurrent.atomic.AtomicBoolean;
import org.apache.lucene.analysis.Analyzer;
@@ -147,15 +148,14 @@ public class TestConjunctions extends LuceneTestCase {
private final AtomicBoolean setScorerCalled = new AtomicBoolean(false);
@Override
- public void setScorer(Scorable s) throws IOException {
- Collection<Scorer.ChildScorable> childScorers = s.getChildren();
- setScorerCalled.set(true);
- assertEquals(2, childScorers.size());
+ public void setWeight(Weight weight) {
+ BooleanQuery query = (BooleanQuery) weight.getQuery();
+ List<BooleanClause> clauseList = query.clauses();
+ assertEquals(2, clauseList.size());
Set<String> terms = new HashSet<>();
- for (Scorer.ChildScorable childScorer : childScorers) {
- Query query = ((Scorer) childScorer.child).getWeight().getQuery();
- assertTrue(query instanceof TermQuery);
- Term term = ((TermQuery) query).getTerm();
+ for (BooleanClause clause : clauseList) {
+ assert (clause.query() instanceof TermQuery);
+ Term term = ((TermQuery) clause.query()).getTerm();
assertEquals("field", term.field());
terms.add(term.text());
}
@@ -164,6 +164,13 @@ public class TestConjunctions extends LuceneTestCase {
assertTrue(terms.contains("b"));
}
+ @Override
+ public void setScorer(Scorable s) throws IOException {
+ Collection<Scorer.ChildScorable> childScorers = s.getChildren();
+ setScorerCalled.set(true);
+ assertEquals(2, childScorers.size());
+ }
+
@Override
public void collect(int doc) {}
diff --git a/lucene/core/src/test/org/apache/lucene/search/TestConstantScoreScorer.java b/lucene/core/src/test/org/apache/lucene/search/TestConstantScoreScorer.java
index 2f1125cb11a..e10ed44890e 100644
--- a/lucene/core/src/test/org/apache/lucene/search/TestConstantScoreScorer.java
+++ b/lucene/core/src/test/org/apache/lucene/search/TestConstantScoreScorer.java
@@ -205,10 +205,9 @@ public class TestConstantScoreScorer extends LuceneTestCase {
Scorer scorer = weight.scorer(context);
if (scorer.twoPhaseIterator() == null) {
- return new ConstantScoreScorer(scorer.getWeight(), score, scoreMode, scorer.iterator());
+ return new ConstantScoreScorer(score, scoreMode, scorer.iterator());
} else {
- return new ConstantScoreScorer(
- scorer.getWeight(), score, scoreMode, scorer.twoPhaseIterator());
+ return new ConstantScoreScorer(score, scoreMode, scorer.twoPhaseIterator());
}
}
diff --git a/lucene/core/src/test/org/apache/lucene/search/TestDisiPriorityQueue.java b/lucene/core/src/test/org/apache/lucene/search/TestDisiPriorityQueue.java
index 0826cbe7ee9..62dc0a94ca3 100644
--- a/lucene/core/src/test/org/apache/lucene/search/TestDisiPriorityQueue.java
+++ b/lucene/core/src/test/org/apache/lucene/search/TestDisiPriorityQueue.java
@@ -125,7 +125,7 @@ public class TestDisiPriorityQueue extends LuceneTestCase {
return new ConstantScoreWeight(this, boost) {
@Override
public ScorerSupplier scorerSupplier(LeafReaderContext context) throws IOException {
- final var scorer = new ConstantScoreScorer(this, score(), scoreMode, disi);
+ final var scorer = new ConstantScoreScorer(score(), scoreMode, disi);
return new DefaultScorerSupplier(scorer);
}
diff --git a/lucene/core/src/test/org/apache/lucene/search/TestDisjunctionScoreBlockBoundaryPropagator.java b/lucene/core/src/test/org/apache/lucene/search/TestDisjunctionScoreBlockBoundaryPropagator.java
index 803e7a04d98..387e4f984a5 100644
--- a/lucene/core/src/test/org/apache/lucene/search/TestDisjunctionScoreBlockBoundaryPropagator.java
+++ b/lucene/core/src/test/org/apache/lucene/search/TestDisjunctionScoreBlockBoundaryPropagator.java
@@ -20,40 +20,15 @@ import java.io.IOException;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
-import org.apache.lucene.index.LeafReaderContext;
import org.apache.lucene.tests.util.LuceneTestCase;
public class TestDisjunctionScoreBlockBoundaryPropagator extends LuceneTestCase {
-
- private static class FakeWeight extends Weight {
-
- FakeWeight() {
- super(new MatchNoDocsQuery());
- }
-
- @Override
- public Explanation explain(LeafReaderContext context, int doc) throws IOException {
- return null;
- }
-
- @Override
- public ScorerSupplier scorerSupplier(LeafReaderContext context) throws IOException {
- return null;
- }
-
- @Override
- public boolean isCacheable(LeafReaderContext ctx) {
- return false;
- }
- }
-
private static class FakeScorer extends Scorer {
final int boundary;
final float maxScore;
FakeScorer(int boundary, float maxScore) throws IOException {
- super(new FakeWeight());
this.boundary = boundary;
this.maxScore = maxScore;
}
diff --git a/lucene/core/src/test/org/apache/lucene/search/TestLRUQueryCache.java b/lucene/core/src/test/org/apache/lucene/search/TestLRUQueryCache.java
index 4b65e52dd44..cd474ed0559 100644
--- a/lucene/core/src/test/org/apache/lucene/search/TestLRUQueryCache.java
+++ b/lucene/core/src/test/org/apache/lucene/search/TestLRUQueryCache.java
@@ -1629,8 +1629,7 @@ public class TestLRUQueryCache extends LuceneTestCase {
@Override
public ScorerSupplier scorerSupplier(LeafReaderContext context) throws IOException {
- final var scorer =
- new ConstantScoreScorer(this, boost, scoreMode, DocIdSetIterator.all(1));
+ final var scorer = new ConstantScoreScorer(boost, scoreMode, DocIdSetIterator.all(1));
return new ScorerSupplier() {
@Override
public Scorer get(long leadCost) throws IOException {
@@ -1722,13 +1721,12 @@ public class TestLRUQueryCache extends LuceneTestCase {
return new ConstantScoreWeight(this, 1) {
@Override
public ScorerSupplier scorerSupplier(LeafReaderContext context) throws IOException {
- final Weight weight = this;
return new ScorerSupplier() {
@Override
public Scorer get(long leadCost) throws IOException {
scorerCreatedCount.incrementAndGet();
return new ConstantScoreScorer(
- weight, 1, scoreMode, DocIdSetIterator.all(context.reader().maxDoc()));
+ 1, scoreMode, DocIdSetIterator.all(context.reader().maxDoc()));
}
@Override
diff --git a/lucene/core/src/test/org/apache/lucene/search/TestMaxScoreBulkScorer.java b/lucene/core/src/test/org/apache/lucene/search/TestMaxScoreBulkScorer.java
index fad7b80a388..4c731201dc6 100644
--- a/lucene/core/src/test/org/apache/lucene/search/TestMaxScoreBulkScorer.java
+++ b/lucene/core/src/test/org/apache/lucene/search/TestMaxScoreBulkScorer.java
@@ -372,38 +372,6 @@ public class TestMaxScoreBulkScorer extends LuceneTestCase {
}
}
- private static class FakeWeight extends Weight {
-
- protected FakeWeight() {
- super(null);
- }
-
- @Override
- public boolean isCacheable(LeafReaderContext ctx) {
- return false;
- }
-
- @Override
- public Explanation explain(LeafReaderContext context, int doc) throws IOException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public ScorerSupplier scorerSupplier(LeafReaderContext context) {
- return new ScorerSupplier() {
- @Override
- public Scorer get(long leadCost) throws IOException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public long cost() {
- throw new UnsupportedOperationException();
- }
- };
- }
- }
-
private static class FakeScorer extends Scorer {
final String toString;
@@ -413,7 +381,6 @@ public class TestMaxScoreBulkScorer extends LuceneTestCase {
int cost = 10;
protected FakeScorer(String toString) {
- super(new FakeWeight());
this.toString = toString;
}
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 1c0c15431b8..95f6f7ee124 100644
--- a/lucene/core/src/test/org/apache/lucene/search/TestMinShouldMatch2.java
+++ b/lucene/core/src/test/org/apache/lucene/search/TestMinShouldMatch2.java
@@ -135,7 +135,7 @@ public class TestMinShouldMatch2 extends LuceneTestCase {
}
return null;
}
- return new BulkScorerWrapperScorer(weight, bulkScorer, TestUtil.nextInt(random(), 1, 100));
+ return new BulkScorerWrapperScorer(bulkScorer, TestUtil.nextInt(random(), 1, 100));
default:
throw new AssertionError();
}
@@ -351,7 +351,6 @@ public class TestMinShouldMatch2 extends LuceneTestCase {
SlowMinShouldMatchScorer(BooleanWeight weight, LeafReader reader, IndexSearcher searcher)
throws IOException {
- super(weight);
this.dv = reader.getSortedSetDocValues("dv");
this.maxDoc = reader.maxDoc();
BooleanQuery bq = (BooleanQuery) weight.getQuery();
diff --git a/lucene/core/src/test/org/apache/lucene/search/TestPositiveScoresOnlyCollector.java b/lucene/core/src/test/org/apache/lucene/search/TestPositiveScoresOnlyCollector.java
index dcf644ad1a0..c128945bd42 100644
--- a/lucene/core/src/test/org/apache/lucene/search/TestPositiveScoresOnlyCollector.java
+++ b/lucene/core/src/test/org/apache/lucene/search/TestPositiveScoresOnlyCollector.java
@@ -19,7 +19,6 @@ package org.apache.lucene.search;
import java.io.IOException;
import org.apache.lucene.document.Document;
import org.apache.lucene.index.IndexReader;
-import org.apache.lucene.index.Term;
import org.apache.lucene.store.Directory;
import org.apache.lucene.tests.index.RandomIndexWriter;
import org.apache.lucene.tests.util.LuceneTestCase;
@@ -29,10 +28,6 @@ public class TestPositiveScoresOnlyCollector extends LuceneTestCase {
private static final class SimpleScorer extends Scorer {
private int idx = -1;
- public SimpleScorer(Weight weight) {
- super(weight);
- }
-
@Override
public float score() {
return idx == scores.length ? Float.NaN : scores[idx];
@@ -113,10 +108,7 @@ public class TestPositiveScoresOnlyCollector extends LuceneTestCase {
writer.commit();
IndexReader ir = writer.getReader();
writer.close();
- IndexSearcher searcher = newSearcher(ir);
- Weight fake =
- new TermQuery(new Term("fake", "weight")).createWeight(searcher, ScoreMode.COMPLETE, 1f);
- Scorer s = new SimpleScorer(fake);
+ Scorer s = new SimpleScorer();
TopDocsCollector<ScoreDoc> tdc = TopScoreDocCollector.create(scores.length, Integer.MAX_VALUE);
Collector c = new PositiveScoresOnlyCollector(tdc);
LeafCollector ac = c.getLeafCollector(ir.leaves().get(0));
diff --git a/lucene/core/src/test/org/apache/lucene/search/TestQueryRescorer.java b/lucene/core/src/test/org/apache/lucene/search/TestQueryRescorer.java
index 54131afda8b..d422f85e012 100644
--- a/lucene/core/src/test/org/apache/lucene/search/TestQueryRescorer.java
+++ b/lucene/core/src/test/org/apache/lucene/search/TestQueryRescorer.java
@@ -495,7 +495,7 @@ public class TestQueryRescorer extends LuceneTestCase {
@Override
public ScorerSupplier scorerSupplier(LeafReaderContext context) throws IOException {
final var scorer =
- new Scorer(this) {
+ new Scorer() {
int docID = -1;
@Override
diff --git a/lucene/core/src/test/org/apache/lucene/search/TestScoreCachingWrappingScorer.java b/lucene/core/src/test/org/apache/lucene/search/TestScoreCachingWrappingScorer.java
index 43be0710887..6131541caa3 100644
--- a/lucene/core/src/test/org/apache/lucene/search/TestScoreCachingWrappingScorer.java
+++ b/lucene/core/src/test/org/apache/lucene/search/TestScoreCachingWrappingScorer.java
@@ -19,7 +19,6 @@ package org.apache.lucene.search;
import java.io.IOException;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.LeafReaderContext;
-import org.apache.lucene.index.Term;
import org.apache.lucene.store.Directory;
import org.apache.lucene.tests.index.RandomIndexWriter;
import org.apache.lucene.tests.util.LuceneTestCase;
@@ -30,10 +29,6 @@ public class TestScoreCachingWrappingScorer extends LuceneTestCase {
private int idx = 0;
private int doc = -1;
- public SimpleScorer(Weight weight) {
- super(weight);
- }
-
@Override
public float score() {
// advance idx on purpose, so that consecutive calls to score will get
@@ -145,10 +140,7 @@ public class TestScoreCachingWrappingScorer extends LuceneTestCase {
writer.commit();
IndexReader ir = writer.getReader();
writer.close();
- IndexSearcher searcher = newSearcher(ir);
- Weight fake =
- new TermQuery(new Term("fake", "weight")).createWeight(searcher, ScoreMode.COMPLETE, 1f);
- Scorer s = new SimpleScorer(fake);
+ Scorer s = new SimpleScorer();
ScoreCachingCollector scc = new ScoreCachingCollector(scores.length);
LeafCollector lc = scc.getLeafCollector(null);
lc.setScorer(s);
diff --git a/lucene/core/src/test/org/apache/lucene/search/TestScorerPerf.java b/lucene/core/src/test/org/apache/lucene/search/TestScorerPerf.java
index 04d8c64671c..25404eacb30 100644
--- a/lucene/core/src/test/org/apache/lucene/search/TestScorerPerf.java
+++ b/lucene/core/src/test/org/apache/lucene/search/TestScorerPerf.java
@@ -170,10 +170,7 @@ public class TestScorerPerf extends LuceneTestCase {
public ScorerSupplier scorerSupplier(LeafReaderContext context) throws IOException {
final var scorer =
new ConstantScoreScorer(
- this,
- score(),
- scoreMode,
- new BitSetIterator(docs, docs.approximateCardinality()));
+ score(), scoreMode, new BitSetIterator(docs, docs.approximateCardinality()));
return new DefaultScorerSupplier(scorer);
}
diff --git a/lucene/core/src/test/org/apache/lucene/search/TestSortRandom.java b/lucene/core/src/test/org/apache/lucene/search/TestSortRandom.java
index 41faa770583..35b44fd719c 100644
--- a/lucene/core/src/test/org/apache/lucene/search/TestSortRandom.java
+++ b/lucene/core/src/test/org/apache/lucene/search/TestSortRandom.java
@@ -268,10 +268,7 @@ public class TestSortRandom extends LuceneTestCase {
final var scorer =
new ConstantScoreScorer(
- this,
- score(),
- scoreMode,
- new BitSetIterator(bits, bits.approximateCardinality()));
+ score(), scoreMode, new BitSetIterator(bits, bits.approximateCardinality()));
return new DefaultScorerSupplier(scorer);
}
diff --git a/lucene/core/src/test/org/apache/lucene/search/TestSubScorerFreqs.java b/lucene/core/src/test/org/apache/lucene/search/TestSubScorerFreqs.java
deleted file mode 100644
index cc2cf69bba8..00000000000
--- a/lucene/core/src/test/org/apache/lucene/search/TestSubScorerFreqs.java
+++ /dev/null
@@ -1,270 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.lucene.search;
-
-import java.io.IOException;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-import org.apache.lucene.document.Document;
-import org.apache.lucene.document.Field;
-import org.apache.lucene.index.FieldInvertState;
-import org.apache.lucene.index.LeafReaderContext;
-import org.apache.lucene.index.Term;
-import org.apache.lucene.search.BooleanClause.Occur;
-import org.apache.lucene.search.similarities.Similarity;
-import org.apache.lucene.store.ByteBuffersDirectory;
-import org.apache.lucene.store.Directory;
-import org.apache.lucene.tests.analysis.MockAnalyzer;
-import org.apache.lucene.tests.index.RandomIndexWriter;
-import org.apache.lucene.tests.search.AssertingScorable;
-import org.apache.lucene.tests.search.DisablingBulkScorerQuery;
-import org.apache.lucene.tests.util.LuceneTestCase;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-public class TestSubScorerFreqs extends LuceneTestCase {
-
- private static Directory dir;
- private static IndexSearcher s;
-
- @BeforeClass
- public static void makeIndex() throws Exception {
- dir = new ByteBuffersDirectory();
- RandomIndexWriter w =
- new RandomIndexWriter(
- random(),
- dir,
- newIndexWriterConfig(new MockAnalyzer(random())).setMergePolicy(newLogMergePolicy()));
- // make sure we have more than one segment occationally
- int num = atLeast(31);
- for (int i = 0; i < num; i++) {
- Document doc = new Document();
- doc.add(newTextField("f", "a b c d b c d c d d", Field.Store.NO));
- w.addDocument(doc);
-
- doc = new Document();
- doc.add(newTextField("f", "a b c d", Field.Store.NO));
- w.addDocument(doc);
- }
-
- s = newSearcher(w.getReader());
- s.setSimilarity(new CountingSimilarity());
- w.close();
- }
-
- @AfterClass
- public static void finish() throws Exception {
- s.getIndexReader().close();
- s = null;
- dir.close();
- dir = null;
- }
-
- private static class CountingCollectorManager
- implements CollectorManager<CountingCollector, Map<Integer, Map<Query, Float>>> {
-
- private final Set<String> relationships;
-
- CountingCollectorManager(Set<String> relationships) {
- this.relationships = relationships;
- }
-
- @Override
- public CountingCollector newCollector() {
- TopScoreDocCollector topScoreDocCollector =
- TopScoreDocCollector.create(10, Integer.MAX_VALUE);
- return relationships == null
- ? new CountingCollector(topScoreDocCollector)
- : new CountingCollector(topScoreDocCollector, relationships);
- }
-
- @Override
- public Map<Integer, Map<Query, Float>> reduce(Collection<CountingCollector> collectors) {
- Map<Integer, Map<Query, Float>> docCounts = new HashMap<>();
- for (CountingCollector collector : collectors) {
- docCounts.putAll(collector.docCounts);
- }
- return docCounts;
- }
- }
-
- private static class CountingCollector extends FilterCollector {
- public final Map<Integer, Map<Query, Float>> docCounts = new HashMap<>();
-
- private final Map<Query, Scorer> subScorers = new HashMap<>();
- private final Set<String> relationships;
-
- public CountingCollector(Collector other) {
- this(other, new HashSet<>(Arrays.asList("MUST", "SHOULD", "MUST_NOT")));
- }
-
- public CountingCollector(Collector other, Set<String> relationships) {
- super(other);
- this.relationships = relationships;
- }
-
- public void setSubScorers(Scorable scorer) throws IOException {
- scorer = AssertingScorable.unwrap(scorer);
- for (Scorable.ChildScorable child : scorer.getChildren()) {
- if (relationships.contains(child.relationship)) {
- setSubScorers(child.child);
- }
- }
- subScorers.put(((Scorer) scorer).getWeight().getQuery(), (Scorer) scorer);
- }
-
- @Override
- public LeafCollector getLeafCollector(LeafReaderContext context) throws IOException {
- final int docBase = context.docBase;
- return new FilterLeafCollector(super.getLeafCollector(context)) {
-
- @Override
- public void collect(int doc) throws IOException {
- final Map<Query, Float> freqs = new HashMap<Query, Float>();
- for (Map.Entry<Query, Scorer> ent : subScorers.entrySet()) {
- Scorer value = ent.getValue();
- int matchId = value.docID();
- freqs.put(ent.getKey(), matchId == doc ? value.score() : 0.0f);
- }
- docCounts.put(doc + docBase, freqs);
- super.collect(doc);
- }
-
- @Override
- public void setScorer(Scorable scorer) throws IOException {
- super.setScorer(scorer);
- subScorers.clear();
- setSubScorers(scorer);
- }
- };
- }
- }
-
- private static final float FLOAT_TOLERANCE = 0.00001F;
-
- @Test
- public void testTermQuery() throws Exception {
- TermQuery q = new TermQuery(new Term("f", "d"));
- Map<Integer, Map<Query, Float>> docCounts = s.search(q, new CountingCollectorManager(null));
- final int maxDocs = s.getIndexReader().maxDoc();
- assertEquals(maxDocs, docCounts.size());
- for (int i = 0; i < maxDocs; i++) {
- Map<Query, Float> doc0 = docCounts.get(i);
- assertEquals(1, doc0.size());
- assertEquals(4.0F, doc0.get(q), FLOAT_TOLERANCE);
-
- Map<Query, Float> doc1 = docCounts.get(++i);
- assertEquals(1, doc1.size());
- assertEquals(1.0F, doc1.get(q), FLOAT_TOLERANCE);
- }
- }
-
- @Test
- public void testBooleanQuery() throws Exception {
- TermQuery aQuery = new TermQuery(new Term("f", "a"));
- TermQuery dQuery = new TermQuery(new Term("f", "d"));
- TermQuery cQuery = new TermQuery(new Term("f", "c"));
- TermQuery yQuery = new TermQuery(new Term("f", "y"));
-
- BooleanQuery.Builder query = new BooleanQuery.Builder();
- BooleanQuery.Builder inner = new BooleanQuery.Builder();
-
- inner.add(cQuery, Occur.SHOULD);
- inner.add(yQuery, Occur.MUST_NOT);
- query.add(inner.build(), Occur.MUST);
- query.add(aQuery, Occur.MUST);
- query.add(dQuery, Occur.MUST);
-
- // Only needed in Java6; Java7+ has a @SafeVarargs annotated Arrays#asList()!
- // see http://docs.oracle.com/javase/7/docs/api/java/lang/SafeVarargs.html
- @SuppressWarnings("unchecked")
- final Iterable<Set<String>> occurList =
- Arrays.asList(
- Collections.singleton("MUST"), new HashSet<>(Arrays.asList("MUST", "SHOULD")));
-
- for (final Set<String> occur : occurList) {
- Map<Integer, Map<Query, Float>> docCounts =
- s.search(
- new DisablingBulkScorerQuery(query.build()), new CountingCollectorManager(occur));
- final int maxDocs = s.getIndexReader().maxDoc();
- assertEquals(maxDocs, docCounts.size());
- boolean includeOptional = occur.contains("SHOULD");
- for (int i = 0; i < maxDocs; i++) {
- Map<Query, Float> doc0 = docCounts.get(i);
- // Y doesnt exist in the index, so it's not in the scorer tree
- assertEquals(4, doc0.size());
- assertEquals(1.0F, doc0.get(aQuery), FLOAT_TOLERANCE);
- assertEquals(4.0F, doc0.get(dQuery), FLOAT_TOLERANCE);
- if (includeOptional) {
- assertEquals(3.0F, doc0.get(cQuery), FLOAT_TOLERANCE);
- }
-
- Map<Query, Float> doc1 = docCounts.get(++i);
- // Y doesnt exist in the index, so it's not in the scorer tree
- assertEquals(4, doc1.size());
- assertEquals(1.0F, doc1.get(aQuery), FLOAT_TOLERANCE);
- assertEquals(1.0F, doc1.get(dQuery), FLOAT_TOLERANCE);
- if (includeOptional) {
- assertEquals(1.0F, doc1.get(cQuery), FLOAT_TOLERANCE);
- }
- }
- }
- }
-
- @Test
- public void testPhraseQuery() throws Exception {
- PhraseQuery q = new PhraseQuery("f", "b", "c");
- Map<Integer, Map<Query, Float>> docCounts = s.search(q, new CountingCollectorManager(null));
- final int maxDocs = s.getIndexReader().maxDoc();
- assertEquals(maxDocs, docCounts.size());
- for (int i = 0; i < maxDocs; i++) {
- Map<Query, Float> doc0 = docCounts.get(i);
- assertEquals(1, doc0.size());
- assertEquals(2.0F, doc0.get(q), FLOAT_TOLERANCE);
-
- Map<Query, Float> doc1 = docCounts.get(++i);
- assertEquals(1, doc1.size());
- assertEquals(1.0F, doc1.get(q), FLOAT_TOLERANCE);
- }
- }
-
- // Similarity that just returns the frequency as the score
- private static class CountingSimilarity extends Similarity {
-
- @Override
- public long computeNorm(FieldInvertState state) {
- return 1;
- }
-
- @Override
- public SimScorer scorer(
- float boost, CollectionStatistics collectionStats, TermStatistics... termStats) {
- return new SimScorer() {
- @Override
- public float score(float freq, long norm) {
- return freq;
- }
- };
- }
- }
-}
diff --git a/lucene/core/src/test/org/apache/lucene/search/TestUsageTrackingFilterCachingPolicy.java b/lucene/core/src/test/org/apache/lucene/search/TestUsageTrackingFilterCachingPolicy.java
index 03089f8c2dc..4ae0d161087 100644
--- a/lucene/core/src/test/org/apache/lucene/search/TestUsageTrackingFilterCachingPolicy.java
+++ b/lucene/core/src/test/org/apache/lucene/search/TestUsageTrackingFilterCachingPolicy.java
@@ -134,8 +134,7 @@ public class TestUsageTrackingFilterCachingPolicy extends LuceneTestCase {
return new ConstantScoreWeight(DummyQuery.this, boost) {
@Override
public ScorerSupplier scorerSupplier(LeafReaderContext context) throws IOException {
- final var scorer =
- new ConstantScoreScorer(this, score(), scoreMode, DocIdSetIterator.all(1));
+ final var scorer = new ConstantScoreScorer(score(), scoreMode, DocIdSetIterator.all(1));
return new DefaultScorerSupplier(scorer);
}
diff --git a/lucene/core/src/test/org/apache/lucene/search/TestWANDScorer.java b/lucene/core/src/test/org/apache/lucene/search/TestWANDScorer.java
index 88bc3ad7460..678a0812ebc 100644
--- a/lucene/core/src/test/org/apache/lucene/search/TestWANDScorer.java
+++ b/lucene/core/src/test/org/apache/lucene/search/TestWANDScorer.java
@@ -1024,8 +1024,7 @@ public class TestWANDScorer extends LuceneTestCase {
final Scorer scorer;
if (optionalScorers.size() > 0) {
scorer =
- new WANDScorer(
- weight, optionalScorers, query.getMinimumNumberShouldMatch(), scoreMode);
+ new WANDScorer(optionalScorers, query.getMinimumNumberShouldMatch(), scoreMode);
} else {
scorer = weight.scorer(context);
if (scorer == null) return null;
diff --git a/lucene/facet/src/java/org/apache/lucene/facet/DrillSidewaysQuery.java b/lucene/facet/src/java/org/apache/lucene/facet/DrillSidewaysQuery.java
index ef41ae38071..dca425f40f4 100644
--- a/lucene/facet/src/java/org/apache/lucene/facet/DrillSidewaysQuery.java
+++ b/lucene/facet/src/java/org/apache/lucene/facet/DrillSidewaysQuery.java
@@ -180,8 +180,7 @@ class DrillSidewaysQuery extends Query {
Scorer scorer = drillDowns[dim].scorer(context);
if (scorer == null) {
nullCount++;
- scorer =
- new ConstantScoreScorer(drillDowns[dim], 0f, scoreMode, DocIdSetIterator.empty());
+ scorer = new ConstantScoreScorer(0f, scoreMode, DocIdSetIterator.empty());
}
FacetsCollector sidewaysCollector = drillSidewaysCollectorManagers[dim].newCollector();
diff --git a/lucene/facet/src/java/org/apache/lucene/facet/range/DoubleRange.java b/lucene/facet/src/java/org/apache/lucene/facet/range/DoubleRange.java
index 4e8ffb19266..1e9f101f555 100644
--- a/lucene/facet/src/java/org/apache/lucene/facet/range/DoubleRange.java
+++ b/lucene/facet/src/java/org/apache/lucene/facet/range/DoubleRange.java
@@ -202,7 +202,7 @@ public final class DoubleRange extends Range {
return 100; // TODO: use cost of range.accept()
}
};
- final var scorer = new ConstantScoreScorer(this, score(), scoreMode, twoPhase);
+ final var scorer = new ConstantScoreScorer(score(), scoreMode, twoPhase);
return new DefaultScorerSupplier(scorer);
}
@@ -309,7 +309,7 @@ public final class DoubleRange extends Range {
return 100; // TODO: use cost of range.accept()
}
};
- final var scorer = new ConstantScoreScorer(this, score(), scoreMode, twoPhase);
+ final var scorer = new ConstantScoreScorer(score(), scoreMode, twoPhase);
return new DefaultScorerSupplier(scorer);
}
diff --git a/lucene/facet/src/java/org/apache/lucene/facet/range/LongRange.java b/lucene/facet/src/java/org/apache/lucene/facet/range/LongRange.java
index 0a749c2d3bb..9869f71718e 100644
--- a/lucene/facet/src/java/org/apache/lucene/facet/range/LongRange.java
+++ b/lucene/facet/src/java/org/apache/lucene/facet/range/LongRange.java
@@ -189,7 +189,7 @@ public final class LongRange extends Range {
return 100; // TODO: use cost of range.accept()
}
};
- final var scorer = new ConstantScoreScorer(this, score(), scoreMode, twoPhase);
+ final var scorer = new ConstantScoreScorer(score(), scoreMode, twoPhase);
return new DefaultScorerSupplier(scorer);
}
@@ -296,7 +296,7 @@ public final class LongRange extends Range {
return 100; // TODO: use cost of range.accept()
}
};
- final var scorer = new ConstantScoreScorer(this, score(), scoreMode, twoPhase);
+ final var scorer = new ConstantScoreScorer(score(), scoreMode, twoPhase);
return new DefaultScorerSupplier(scorer);
}
diff --git a/lucene/facet/src/test/org/apache/lucene/facet/TestDrillSideways.java b/lucene/facet/src/test/org/apache/lucene/facet/TestDrillSideways.java
index 812ae228c7b..5645f191549 100644
--- a/lucene/facet/src/test/org/apache/lucene/facet/TestDrillSideways.java
+++ b/lucene/facet/src/test/org/apache/lucene/facet/TestDrillSideways.java
@@ -1314,7 +1314,6 @@ public class TestDrillSideways extends FacetTestCase {
DocIdSetIterator.all(context.reader().maxDoc());
final var scorer =
new ConstantScoreScorer(
- this,
score(),
scoreMode,
new TwoPhaseIterator(approximation) {
diff --git a/lucene/join/src/java/org/apache/lucene/search/join/BaseGlobalOrdinalScorer.java b/lucene/join/src/java/org/apache/lucene/search/join/BaseGlobalOrdinalScorer.java
index 881cbce37ab..125febd538f 100644
--- a/lucene/join/src/java/org/apache/lucene/search/join/BaseGlobalOrdinalScorer.java
+++ b/lucene/join/src/java/org/apache/lucene/search/join/BaseGlobalOrdinalScorer.java
@@ -21,7 +21,6 @@ import org.apache.lucene.index.SortedDocValues;
import org.apache.lucene.search.DocIdSetIterator;
import org.apache.lucene.search.Scorer;
import org.apache.lucene.search.TwoPhaseIterator;
-import org.apache.lucene.search.Weight;
abstract class BaseGlobalOrdinalScorer extends Scorer {
@@ -32,8 +31,7 @@ abstract class BaseGlobalOrdinalScorer extends Scorer {
float score;
public BaseGlobalOrdinalScorer(
- Weight weight, SortedDocValues values, DocIdSetIterator approximationScorer, float boost) {
- super(weight);
+ SortedDocValues values, DocIdSetIterator approximationScorer, float boost) {
this.values = values;
this.approximation = approximationScorer;
this.boost = boost;
diff --git a/lucene/join/src/java/org/apache/lucene/search/join/GlobalOrdinalsQuery.java b/lucene/join/src/java/org/apache/lucene/search/join/GlobalOrdinalsQuery.java
index c0c150d2337..5505f7ba28c 100644
--- a/lucene/join/src/java/org/apache/lucene/search/join/GlobalOrdinalsQuery.java
+++ b/lucene/join/src/java/org/apache/lucene/search/join/GlobalOrdinalsQuery.java
@@ -184,7 +184,6 @@ final class GlobalOrdinalsQuery extends Query implements Accountable {
if (globalOrds != null) {
scorer =
new OrdinalMapScorer(
- this,
score(),
foundOrds,
values,
@@ -192,8 +191,7 @@ final class GlobalOrdinalsQuery extends Query implements Accountable {
globalOrds.getGlobalOrds(context.ord));
} else {
scorer =
- new SegmentOrdinalScorer(
- this, score(), foundOrds, values, approximationScorer.iterator());
+ new SegmentOrdinalScorer(score(), foundOrds, values, approximationScorer.iterator());
}
return new DefaultScorerSupplier(scorer);
}
@@ -213,13 +211,12 @@ final class GlobalOrdinalsQuery extends Query implements Accountable {
final LongValues segmentOrdToGlobalOrdLookup;
public OrdinalMapScorer(
- Weight weight,
float score,
LongBitSet foundOrds,
SortedDocValues values,
DocIdSetIterator approximationScorer,
LongValues segmentOrdToGlobalOrdLookup) {
- super(weight, values, approximationScorer, 1);
+ super(values, approximationScorer, 1);
this.score = score;
this.foundOrds = foundOrds;
this.segmentOrdToGlobalOrdLookup = segmentOrdToGlobalOrdLookup;
@@ -254,12 +251,11 @@ final class GlobalOrdinalsQuery extends Query implements Accountable {
final LongBitSet foundOrds;
public SegmentOrdinalScorer(
- Weight weight,
float score,
LongBitSet foundOrds,
SortedDocValues values,
DocIdSetIterator approximationScorer) {
- super(weight, values, approximationScorer, 1);
+ super(values, approximationScorer, 1);
this.score = score;
this.foundOrds = foundOrds;
}
diff --git a/lucene/join/src/java/org/apache/lucene/search/join/GlobalOrdinalsWithScoreQuery.java b/lucene/join/src/java/org/apache/lucene/search/join/GlobalOrdinalsWithScoreQuery.java
index 85dbf2ec29c..9b118d3cf2e 100644
--- a/lucene/join/src/java/org/apache/lucene/search/join/GlobalOrdinalsWithScoreQuery.java
+++ b/lucene/join/src/java/org/apache/lucene/search/join/GlobalOrdinalsWithScoreQuery.java
@@ -222,16 +222,13 @@ final class GlobalOrdinalsWithScoreQuery extends Query implements Accountable {
} else if (globalOrds != null) {
scorer =
new OrdinalMapScorer(
- this,
collector,
boost,
values,
approximationScorer.iterator(),
globalOrds.getGlobalOrds(context.ord));
} else {
- scorer =
- new SegmentOrdinalScorer(
- this, collector, values, boost, approximationScorer.iterator());
+ scorer = new SegmentOrdinalScorer(collector, values, boost, approximationScorer.iterator());
}
return new DefaultScorerSupplier(scorer);
}
@@ -251,13 +248,12 @@ final class GlobalOrdinalsWithScoreQuery extends Query implements Accountable {
final GlobalOrdinalsWithScoreCollector collector;
public OrdinalMapScorer(
- Weight weight,
GlobalOrdinalsWithScoreCollector collector,
float boost,
SortedDocValues values,
DocIdSetIterator approximation,
LongValues segmentOrdToGlobalOrdLookup) {
- super(weight, values, approximation, boost);
+ super(values, approximation, boost);
this.segmentOrdToGlobalOrdLookup = segmentOrdToGlobalOrdLookup;
this.collector = collector;
}
@@ -292,12 +288,11 @@ final class GlobalOrdinalsWithScoreQuery extends Query implements Accountable {
final GlobalOrdinalsWithScoreCollector collector;
public SegmentOrdinalScorer(
- Weight weight,
GlobalOrdinalsWithScoreCollector collector,
SortedDocValues values,
float boost,
DocIdSetIterator approximation) {
- super(weight, values, approximation, boost);
+ super(values, approximation, boost);
this.collector = collector;
}
diff --git a/lucene/join/src/java/org/apache/lucene/search/join/ParentChildrenBlockJoinQuery.java b/lucene/join/src/java/org/apache/lucene/search/join/ParentChildrenBlockJoinQuery.java
index 93cef702301..03b6480622b 100644
--- a/lucene/join/src/java/org/apache/lucene/search/join/ParentChildrenBlockJoinQuery.java
+++ b/lucene/join/src/java/org/apache/lucene/search/join/ParentChildrenBlockJoinQuery.java
@@ -177,7 +177,7 @@ public class ParentChildrenBlockJoinQuery extends Query {
}
};
final var scorer =
- new Scorer(this) {
+ new Scorer() {
@Override
public int docID() {
return it.docID();
diff --git a/lucene/join/src/java/org/apache/lucene/search/join/PointInSetIncludingScoreQuery.java b/lucene/join/src/java/org/apache/lucene/search/join/PointInSetIncludingScoreQuery.java
index 64b481d1dba..1ece42078cf 100644
--- a/lucene/join/src/java/org/apache/lucene/search/join/PointInSetIncludingScoreQuery.java
+++ b/lucene/join/src/java/org/apache/lucene/search/join/PointInSetIncludingScoreQuery.java
@@ -204,7 +204,7 @@ abstract class PointInSetIncludingScoreQuery extends Query implements Accountabl
float[] scores = new float[reader.maxDoc()];
values.intersect(new MergePointVisitor(sortedPackedPoints, result, scores));
final var scorer =
- new Scorer(this) {
+ new Scorer() {
DocIdSetIterator disi = new BitSetIterator(result, 10L);
diff --git a/lucene/join/src/java/org/apache/lucene/search/join/TermsIncludingScoreQuery.java b/lucene/join/src/java/org/apache/lucene/search/join/TermsIncludingScoreQuery.java
index 8864084a001..a3fa1685844 100644
--- a/lucene/join/src/java/org/apache/lucene/search/join/TermsIncludingScoreQuery.java
+++ b/lucene/join/src/java/org/apache/lucene/search/join/TermsIncludingScoreQuery.java
@@ -183,11 +183,9 @@ class TermsIncludingScoreQuery extends Query implements Accountable {
TermsEnum segmentTermsEnum = terms.iterator();
if (multipleValuesPerDocument) {
- scorer =
- new MVInOrderScorer(this, segmentTermsEnum, context.reader().maxDoc(), cost, boost);
+ scorer = new MVInOrderScorer(segmentTermsEnum, context.reader().maxDoc(), cost, boost);
} else {
- scorer =
- new SVInOrderScorer(this, segmentTermsEnum, context.reader().maxDoc(), cost, boost);
+ scorer = new SVInOrderScorer(segmentTermsEnum, context.reader().maxDoc(), cost, boost);
}
return new DefaultScorerSupplier(scorer);
}
@@ -206,9 +204,7 @@ class TermsIncludingScoreQuery extends Query implements Accountable {
final long cost;
final float boost;
- SVInOrderScorer(Weight weight, TermsEnum termsEnum, int maxDoc, long cost, float boost)
- throws IOException {
- super(weight);
+ SVInOrderScorer(TermsEnum termsEnum, int maxDoc, long cost, float boost) throws IOException {
FixedBitSet matchingDocs = new FixedBitSet(maxDoc);
this.scores = new float[maxDoc];
fillDocsAndScores(matchingDocs, termsEnum);
@@ -263,9 +259,8 @@ class TermsIncludingScoreQuery extends Query implements Accountable {
// related documents.
class MVInOrderScorer extends SVInOrderScorer {
- MVInOrderScorer(Weight weight, TermsEnum termsEnum, int maxDoc, long cost, float boost)
- throws IOException {
- super(weight, termsEnum, maxDoc, cost, boost);
+ MVInOrderScorer(TermsEnum termsEnum, int maxDoc, long cost, float boost) throws IOException {
+ super(termsEnum, maxDoc, cost, boost);
}
@Override
diff --git a/lucene/join/src/java/org/apache/lucene/search/join/ToChildBlockJoinQuery.java b/lucene/join/src/java/org/apache/lucene/search/join/ToChildBlockJoinQuery.java
index e618623103f..6fd0dc99e6d 100644
--- a/lucene/join/src/java/org/apache/lucene/search/join/ToChildBlockJoinQuery.java
+++ b/lucene/join/src/java/org/apache/lucene/search/join/ToChildBlockJoinQuery.java
@@ -118,7 +118,7 @@ public class ToChildBlockJoinQuery extends Query {
return null;
}
- final var scorer = new ToChildBlockJoinScorer(this, parentScorer, parents, doScores);
+ final var scorer = new ToChildBlockJoinScorer(parentScorer, parents, doScores);
return new DefaultScorerSupplier(scorer);
}
@@ -148,9 +148,7 @@ public class ToChildBlockJoinQuery extends Query {
private int childDoc = -1;
private int parentDoc = 0;
- public ToChildBlockJoinScorer(
- Weight weight, Scorer parentScorer, BitSet parentBits, boolean doScores) {
- super(weight);
+ public ToChildBlockJoinScorer(Scorer parentScorer, BitSet parentBits, boolean doScores) {
this.doScores = doScores;
this.parentBits = parentBits;
this.parentScorer = parentScorer;
diff --git a/lucene/join/src/java/org/apache/lucene/search/join/ToParentBlockJoinQuery.java b/lucene/join/src/java/org/apache/lucene/search/join/ToParentBlockJoinQuery.java
index b7d98650a1e..db21e17ba08 100644
--- a/lucene/join/src/java/org/apache/lucene/search/join/ToParentBlockJoinQuery.java
+++ b/lucene/join/src/java/org/apache/lucene/search/join/ToParentBlockJoinQuery.java
@@ -148,8 +148,7 @@ public class ToParentBlockJoinQuery extends Query {
@Override
public Scorer get(long leadCost) throws IOException {
- return new BlockJoinScorer(
- BlockJoinWeight.this, childScorerSupplier.get(leadCost), parents, scoreMode);
+ return new BlockJoinScorer(childScorerSupplier.get(leadCost), parents, scoreMode);
}
@Override
@@ -274,9 +273,7 @@ public class ToParentBlockJoinQuery extends Query {
private final ParentTwoPhase parentTwoPhase;
private float score;
- public BlockJoinScorer(
- Weight weight, Scorer childScorer, BitSet parentBits, ScoreMode scoreMode) {
- super(weight);
+ public BlockJoinScorer(Scorer childScorer, BitSet parentBits, ScoreMode scoreMode) {
// System.out.println("Q.init firstChildDoc=" + firstChildDoc);
this.parentBits = parentBits;
this.childScorer = childScorer;
diff --git a/lucene/join/src/test/org/apache/lucene/search/join/TestJoinUtil.java b/lucene/join/src/test/org/apache/lucene/search/join/TestJoinUtil.java
index ee2caee0033..1e9fc55c598 100644
--- a/lucene/join/src/test/org/apache/lucene/search/join/TestJoinUtil.java
+++ b/lucene/join/src/test/org/apache/lucene/search/join/TestJoinUtil.java
@@ -586,7 +586,7 @@ public class TestJoinUtil extends LuceneTestCase {
}
NumericDocValues price = context.reader().getNumericDocValues(field);
final var scorer =
- new FilterScorer(fieldScorer, this) {
+ new FilterScorer(fieldScorer) {
@Override
public float score() throws IOException {
assertEquals(in.docID(), price.advance(in.docID()));
diff --git a/lucene/misc/src/test/org/apache/lucene/misc/search/TestDiversifiedTopDocsCollector.java b/lucene/misc/src/test/org/apache/lucene/misc/search/TestDiversifiedTopDocsCollector.java
index 72359458fd1..a5f5e9e7f1e 100644
--- a/lucene/misc/src/test/org/apache/lucene/misc/search/TestDiversifiedTopDocsCollector.java
+++ b/lucene/misc/src/test/org/apache/lucene/misc/search/TestDiversifiedTopDocsCollector.java
@@ -534,7 +534,7 @@ public class TestDiversifiedTopDocsCollector extends LuceneTestCase {
final var innerScorer = scorerSupplier.get(Long.MAX_VALUE);
NumericDocValues scoreFactors = DocValues.getNumeric(context.reader(), scoreField);
final var scorer =
- new Scorer(this) {
+ new Scorer() {
@Override
public float score() throws IOException {
diff --git a/lucene/queries/src/java/org/apache/lucene/queries/function/FunctionMatchQuery.java b/lucene/queries/src/java/org/apache/lucene/queries/function/FunctionMatchQuery.java
index 029b41118ad..33b50022a70 100644
--- a/lucene/queries/src/java/org/apache/lucene/queries/function/FunctionMatchQuery.java
+++ b/lucene/queries/src/java/org/apache/lucene/queries/function/FunctionMatchQuery.java
@@ -104,7 +104,7 @@ public final class FunctionMatchQuery extends Query {
return matchCost; // TODO maybe DoubleValuesSource should have a matchCost?
}
};
- final var scorer = new ConstantScoreScorer(this, score(), scoreMode, twoPhase);
+ final var scorer = new ConstantScoreScorer(score(), scoreMode, twoPhase);
return new DefaultScorerSupplier(scorer);
}
diff --git a/lucene/queries/src/java/org/apache/lucene/queries/function/FunctionQuery.java b/lucene/queries/src/java/org/apache/lucene/queries/function/FunctionQuery.java
index 72c37ebbabd..b45ffe789db 100644
--- a/lucene/queries/src/java/org/apache/lucene/queries/function/FunctionQuery.java
+++ b/lucene/queries/src/java/org/apache/lucene/queries/function/FunctionQuery.java
@@ -108,7 +108,6 @@ public class FunctionQuery extends Query {
final FunctionValues vals;
public AllScorer(LeafReaderContext context, FunctionWeight w, float boost) throws IOException {
- super(w);
this.weight = w;
this.boost = boost;
this.reader = context.reader();
diff --git a/lucene/queries/src/java/org/apache/lucene/queries/function/FunctionRangeQuery.java b/lucene/queries/src/java/org/apache/lucene/queries/function/FunctionRangeQuery.java
index 2c29276f20b..7069496e261 100644
--- a/lucene/queries/src/java/org/apache/lucene/queries/function/FunctionRangeQuery.java
+++ b/lucene/queries/src/java/org/apache/lucene/queries/function/FunctionRangeQuery.java
@@ -32,7 +32,7 @@ import org.apache.lucene.search.Weight;
* A Query wrapping a {@link ValueSource} that matches docs in which the values in the value source
* match a configured range. The score is the float value. This can be a slow query if run by itself
* since it must visit all docs; ideally it's combined with other queries. It's mostly a wrapper
- * around {@link FunctionValues#getRangeScorer(Weight, LeafReaderContext, String, String, boolean,
+ * around {@link FunctionValues#getRangeScorer(LeafReaderContext, String, String, boolean,
* boolean)}.
*
* <p>A similar class is {@code org.apache.lucene.search.DocValuesRangeQuery} in the sandbox module.
@@ -169,8 +169,7 @@ public class FunctionRangeQuery extends Query {
public ScorerSupplier scorerSupplier(LeafReaderContext context) throws IOException {
FunctionValues functionValues = valueSource.getValues(vsContext, context);
final var scorer =
- functionValues.getRangeScorer(
- this, context, lowerVal, upperVal, includeLower, includeUpper);
+ functionValues.getRangeScorer(context, lowerVal, upperVal, includeLower, includeUpper);
return new DefaultScorerSupplier(scorer);
}
diff --git a/lucene/queries/src/java/org/apache/lucene/queries/function/FunctionValues.java b/lucene/queries/src/java/org/apache/lucene/queries/function/FunctionValues.java
index ed38e3e723c..ec3eb99a198 100644
--- a/lucene/queries/src/java/org/apache/lucene/queries/function/FunctionValues.java
+++ b/lucene/queries/src/java/org/apache/lucene/queries/function/FunctionValues.java
@@ -20,7 +20,6 @@ import java.io.IOException;
import org.apache.lucene.index.LeafReaderContext;
import org.apache.lucene.search.Explanation;
import org.apache.lucene.search.Scorer;
-import org.apache.lucene.search.Weight;
import org.apache.lucene.util.BytesRefBuilder;
import org.apache.lucene.util.mutable.MutableValue;
import org.apache.lucene.util.mutable.MutableValueFloat;
@@ -204,8 +203,8 @@ public abstract class FunctionValues {
* Yields a {@link Scorer} that matches all documents, and that which produces scores equal to
* {@link #floatVal(int)}.
*/
- public ValueSourceScorer getScorer(Weight weight, LeafReaderContext readerContext) {
- return new ValueSourceScorer(weight, readerContext, this) {
+ public ValueSourceScorer getScorer(LeafReaderContext readerContext) {
+ return new ValueSourceScorer(readerContext, this) {
@Override
public boolean matches(int doc) {
return true;
@@ -227,7 +226,6 @@ public abstract class FunctionValues {
// a setup cost - parsing and normalizing params, and doing a binary search on the StringIndex.
// TODO: change "reader" to LeafReaderContext
public ValueSourceScorer getRangeScorer(
- Weight weight,
LeafReaderContext readerContext,
String lowerVal,
String upperVal,
@@ -252,7 +250,7 @@ public abstract class FunctionValues {
final float u = upper;
if (includeLower && includeUpper) {
- return new ValueSourceScorer(weight, readerContext, this) {
+ return new ValueSourceScorer(readerContext, this) {
@Override
public boolean matches(int doc) throws IOException {
if (!exists(doc)) return false;
@@ -261,7 +259,7 @@ public abstract class FunctionValues {
}
};
} else if (includeLower && !includeUpper) {
- return new ValueSourceScorer(weight, readerContext, this) {
+ return new ValueSourceScorer(readerContext, this) {
@Override
public boolean matches(int doc) throws IOException {
if (!exists(doc)) return false;
@@ -270,7 +268,7 @@ public abstract class FunctionValues {
}
};
} else if (!includeLower && includeUpper) {
- return new ValueSourceScorer(weight, readerContext, this) {
+ return new ValueSourceScorer(readerContext, this) {
@Override
public boolean matches(int doc) throws IOException {
if (!exists(doc)) return false;
@@ -279,7 +277,7 @@ public abstract class FunctionValues {
}
};
} else {
- return new ValueSourceScorer(weight, readerContext, this) {
+ return new ValueSourceScorer(readerContext, this) {
@Override
public boolean matches(int doc) throws IOException {
if (!exists(doc)) return false;
diff --git a/lucene/queries/src/java/org/apache/lucene/queries/function/ValueSourceScorer.java b/lucene/queries/src/java/org/apache/lucene/queries/function/ValueSourceScorer.java
index 8b15a7a64cd..8090b3f9ca3 100644
--- a/lucene/queries/src/java/org/apache/lucene/queries/function/ValueSourceScorer.java
+++ b/lucene/queries/src/java/org/apache/lucene/queries/function/ValueSourceScorer.java
@@ -21,7 +21,6 @@ import org.apache.lucene.index.LeafReaderContext;
import org.apache.lucene.search.DocIdSetIterator;
import org.apache.lucene.search.Scorer;
import org.apache.lucene.search.TwoPhaseIterator;
-import org.apache.lucene.search.Weight;
/**
* {@link Scorer} which returns the result of {@link FunctionValues#floatVal(int)} as the score for
@@ -43,9 +42,7 @@ public abstract class ValueSourceScorer extends Scorer {
private final TwoPhaseIterator twoPhaseIterator;
private final DocIdSetIterator disi;
- protected ValueSourceScorer(
- Weight weight, LeafReaderContext readerContext, FunctionValues values) {
- super(weight);
+ protected ValueSourceScorer(LeafReaderContext readerContext, FunctionValues values) {
this.values = values;
final DocIdSetIterator approximation =
DocIdSetIterator.all(readerContext.reader().maxDoc()); // no approximation!
diff --git a/lucene/queries/src/java/org/apache/lucene/queries/function/docvalues/DocTermsIndexDocValues.java b/lucene/queries/src/java/org/apache/lucene/queries/function/docvalues/DocTermsIndexDocValues.java
index adaadd2efc3..5e9449658b7 100644
--- a/lucene/queries/src/java/org/apache/lucene/queries/function/docvalues/DocTermsIndexDocValues.java
+++ b/lucene/queries/src/java/org/apache/lucene/queries/function/docvalues/DocTermsIndexDocValues.java
@@ -23,7 +23,6 @@ import org.apache.lucene.index.SortedDocValues;
import org.apache.lucene.queries.function.FunctionValues;
import org.apache.lucene.queries.function.ValueSource;
import org.apache.lucene.queries.function.ValueSourceScorer;
-import org.apache.lucene.search.Weight;
import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.BytesRefBuilder;
import org.apache.lucene.util.CharsRefBuilder;
@@ -117,7 +116,6 @@ public abstract class DocTermsIndexDocValues extends FunctionValues {
@Override
public ValueSourceScorer getRangeScorer(
- Weight weight,
LeafReaderContext readerContext,
String lowerVal,
String upperVal,
@@ -151,7 +149,7 @@ public abstract class DocTermsIndexDocValues extends FunctionValues {
final int ll = lower;
final int uu = upper;
- return new ValueSourceScorer(weight, readerContext, this) {
+ return new ValueSourceScorer(readerContext, this) {
@Override
public boolean matches(int doc) throws IOException {
if (!exists(doc)) return false;
diff --git a/lucene/queries/src/java/org/apache/lucene/queries/function/docvalues/DoubleDocValues.java b/lucene/queries/src/java/org/apache/lucene/queries/function/docvalues/DoubleDocValues.java
index 321704593c2..c5e5ff1d2bc 100644
--- a/lucene/queries/src/java/org/apache/lucene/queries/function/docvalues/DoubleDocValues.java
+++ b/lucene/queries/src/java/org/apache/lucene/queries/function/docvalues/DoubleDocValues.java
@@ -21,7 +21,6 @@ import org.apache.lucene.index.LeafReaderContext;
import org.apache.lucene.queries.function.FunctionValues;
import org.apache.lucene.queries.function.ValueSource;
import org.apache.lucene.queries.function.ValueSourceScorer;
-import org.apache.lucene.search.Weight;
import org.apache.lucene.util.mutable.MutableValue;
import org.apache.lucene.util.mutable.MutableValueDouble;
@@ -86,7 +85,6 @@ public abstract class DoubleDocValues extends FunctionValues {
@Override
public ValueSourceScorer getRangeScorer(
- Weight weight,
LeafReaderContext readerContext,
String lowerVal,
String upperVal,
@@ -110,7 +108,7 @@ public abstract class DoubleDocValues extends FunctionValues {
final double u = upper;
if (includeLower && includeUpper) {
- return new ValueSourceScorer(weight, readerContext, this) {
+ return new ValueSourceScorer(readerContext, this) {
@Override
public boolean matches(int doc) throws IOException {
if (!exists(doc)) return false;
@@ -119,7 +117,7 @@ public abstract class DoubleDocValues extends FunctionValues {
}
};
} else if (includeLower && !includeUpper) {
- return new ValueSourceScorer(weight, readerContext, this) {
+ return new ValueSourceScorer(readerContext, this) {
@Override
public boolean matches(int doc) throws IOException {
if (!exists(doc)) return false;
@@ -128,7 +126,7 @@ public abstract class DoubleDocValues extends FunctionValues {
}
};
} else if (!includeLower && includeUpper) {
- return new ValueSourceScorer(weight, readerContext, this) {
+ return new ValueSourceScorer(readerContext, this) {
@Override
public boolean matches(int doc) throws IOException {
if (!exists(doc)) return false;
@@ -137,7 +135,7 @@ public abstract class DoubleDocValues extends FunctionValues {
}
};
} else {
- return new ValueSourceScorer(weight, readerContext, this) {
+ return new ValueSourceScorer(readerContext, this) {
@Override
public boolean matches(int doc) throws IOException {
if (!exists(doc)) return false;
diff --git a/lucene/queries/src/java/org/apache/lucene/queries/function/docvalues/IntDocValues.java b/lucene/queries/src/java/org/apache/lucene/queries/function/docvalues/IntDocValues.java
index 58c19c6ae6e..79c4aa29744 100644
--- a/lucene/queries/src/java/org/apache/lucene/queries/function/docvalues/IntDocValues.java
+++ b/lucene/queries/src/java/org/apache/lucene/queries/function/docvalues/IntDocValues.java
@@ -21,7 +21,6 @@ import org.apache.lucene.index.LeafReaderContext;
import org.apache.lucene.queries.function.FunctionValues;
import org.apache.lucene.queries.function.ValueSource;
import org.apache.lucene.queries.function.ValueSourceScorer;
-import org.apache.lucene.search.Weight;
import org.apache.lucene.util.mutable.MutableValue;
import org.apache.lucene.util.mutable.MutableValueInt;
@@ -81,7 +80,6 @@ public abstract class IntDocValues extends FunctionValues {
@Override
public ValueSourceScorer getRangeScorer(
- Weight weight,
LeafReaderContext readerContext,
String lowerVal,
String upperVal,
@@ -108,7 +106,7 @@ public abstract class IntDocValues extends FunctionValues {
final int ll = lower;
final int uu = upper;
- return new ValueSourceScorer(weight, readerContext, this) {
+ return new ValueSourceScorer(readerContext, this) {
@Override
public boolean matches(int doc) throws IOException {
if (!exists(doc)) return false;
diff --git a/lucene/queries/src/java/org/apache/lucene/queries/function/docvalues/LongDocValues.java b/lucene/queries/src/java/org/apache/lucene/queries/function/docvalues/LongDocValues.java
index 375c84fa4e3..be57a8bc03d 100644
--- a/lucene/queries/src/java/org/apache/lucene/queries/function/docvalues/LongDocValues.java
+++ b/lucene/queries/src/java/org/apache/lucene/queries/function/docvalues/LongDocValues.java
@@ -21,7 +21,6 @@ import org.apache.lucene.index.LeafReaderContext;
import org.apache.lucene.queries.function.FunctionValues;
import org.apache.lucene.queries.function.ValueSource;
import org.apache.lucene.queries.function.ValueSourceScorer;
-import org.apache.lucene.search.Weight;
import org.apache.lucene.util.mutable.MutableValue;
import org.apache.lucene.util.mutable.MutableValueLong;
@@ -90,7 +89,6 @@ public abstract class LongDocValues extends FunctionValues {
@Override
public ValueSourceScorer getRangeScorer(
- Weight weight,
LeafReaderContext readerContext,
String lowerVal,
String upperVal,
@@ -117,7 +115,7 @@ public abstract class LongDocValues extends FunctionValues {
final long ll = lower;
final long uu = upper;
- return new ValueSourceScorer(weight, readerContext, this) {
+ return new ValueSourceScorer(readerContext, this) {
@Override
public boolean matches(int doc) throws IOException {
if (!exists(doc)) return false;
diff --git a/lucene/queries/src/java/org/apache/lucene/queries/function/valuesource/EnumFieldSource.java b/lucene/queries/src/java/org/apache/lucene/queries/function/valuesource/EnumFieldSource.java
index a618513bafe..c46c890d7a7 100644
--- a/lucene/queries/src/java/org/apache/lucene/queries/function/valuesource/EnumFieldSource.java
+++ b/lucene/queries/src/java/org/apache/lucene/queries/function/valuesource/EnumFieldSource.java
@@ -24,7 +24,6 @@ import org.apache.lucene.index.NumericDocValues;
import org.apache.lucene.queries.function.FunctionValues;
import org.apache.lucene.queries.function.ValueSourceScorer;
import org.apache.lucene.queries.function.docvalues.IntDocValues;
-import org.apache.lucene.search.Weight;
/**
* Obtains int field values from {@link org.apache.lucene.index.LeafReader#getNumericDocValues} and
@@ -135,7 +134,6 @@ public class EnumFieldSource extends FieldCacheSource {
@Override
public ValueSourceScorer getRangeScorer(
- Weight weight,
LeafReaderContext readerContext,
String lowerVal,
String upperVal,
@@ -161,7 +159,7 @@ public class EnumFieldSource extends FieldCacheSource {
final int ll = lower;
final int uu = upper;
- return new ValueSourceScorer(weight, readerContext, this) {
+ return new ValueSourceScorer(readerContext, this) {
@Override
public boolean matches(int doc) throws IOException {
if (!exists(doc)) return false;
diff --git a/lucene/queries/src/java/org/apache/lucene/queries/intervals/IntervalQuery.java b/lucene/queries/src/java/org/apache/lucene/queries/intervals/IntervalQuery.java
index b42a367f3df..f4f4b749613 100644
--- a/lucene/queries/src/java/org/apache/lucene/queries/intervals/IntervalQuery.java
+++ b/lucene/queries/src/java/org/apache/lucene/queries/intervals/IntervalQuery.java
@@ -192,7 +192,7 @@ public final class IntervalQuery extends Query {
return null;
}
final var scorer =
- new IntervalScorer(this, intervals, intervalsSource.minExtent(), boost, scoreFunction);
+ new IntervalScorer(intervals, intervalsSource.minExtent(), boost, scoreFunction);
return new DefaultScorerSupplier(scorer);
}
diff --git a/lucene/queries/src/java/org/apache/lucene/queries/intervals/IntervalScorer.java b/lucene/queries/src/java/org/apache/lucene/queries/intervals/IntervalScorer.java
index ce096e9ea56..0633d74518f 100644
--- a/lucene/queries/src/java/org/apache/lucene/queries/intervals/IntervalScorer.java
+++ b/lucene/queries/src/java/org/apache/lucene/queries/intervals/IntervalScorer.java
@@ -21,7 +21,6 @@ import java.io.IOException;
import org.apache.lucene.search.DocIdSetIterator;
import org.apache.lucene.search.Scorer;
import org.apache.lucene.search.TwoPhaseIterator;
-import org.apache.lucene.search.Weight;
import org.apache.lucene.search.similarities.Similarity;
class IntervalScorer extends Scorer {
@@ -35,12 +34,7 @@ class IntervalScorer extends Scorer {
private int lastScoredDoc = -1;
IntervalScorer(
- Weight weight,
- IntervalIterator intervals,
- int minExtent,
- float boost,
- IntervalScoreFunction scoreFunction) {
- super(weight);
+ IntervalIterator intervals, int minExtent, float boost, IntervalScoreFunction scoreFunction) {
this.intervals = intervals;
this.minExtent = minExtent;
this.boost = boost;
diff --git a/lucene/queries/src/java/org/apache/lucene/queries/payloads/PayloadScoreQuery.java b/lucene/queries/src/java/org/apache/lucene/queries/payloads/PayloadScoreQuery.java
index f2d9d1aef4c..7c454102779 100644
--- a/lucene/queries/src/java/org/apache/lucene/queries/payloads/PayloadScoreQuery.java
+++ b/lucene/queries/src/java/org/apache/lucene/queries/payloads/PayloadScoreQuery.java
@@ -171,7 +171,7 @@ public class PayloadScoreQuery extends SpanQuery {
Explanation payloadExpl = scorer.getPayloadExplanation();
if (includeSpanScore) {
- SpanWeight innerWeight = ((PayloadSpanWeight) scorer.getWeight()).innerWeight;
+ SpanWeight innerWeight = this.innerWeight;
Explanation innerExpl = innerWeight.explain(context, doc);
return Explanation.match(
scorer.scoreCurrentDoc(), "PayloadSpanQuery, product of:", innerExpl, payloadExpl);
@@ -188,7 +188,7 @@ public class PayloadScoreQuery extends SpanQuery {
}
LeafSimScorer docScorer = innerWeight.getSimScorer(context);
PayloadSpans payloadSpans = new PayloadSpans(spans, decoder);
- final var scorer = new PayloadSpanScorer(this, payloadSpans, docScorer);
+ final var scorer = new PayloadSpanScorer(payloadSpans, docScorer);
return new DefaultScorerSupplier(scorer);
}
}
@@ -244,9 +244,8 @@ public class PayloadScoreQuery extends SpanQuery {
private final PayloadSpans spans;
- private PayloadSpanScorer(SpanWeight weight, PayloadSpans spans, LeafSimScorer docScorer)
- throws IOException {
- super(weight, spans, docScorer);
+ private PayloadSpanScorer(PayloadSpans spans, LeafSimScorer docScorer) throws IOException {
+ super(spans, docScorer);
this.spans = spans;
}
diff --git a/lucene/queries/src/java/org/apache/lucene/queries/payloads/SpanPayloadCheckQuery.java b/lucene/queries/src/java/org/apache/lucene/queries/payloads/SpanPayloadCheckQuery.java
index 8c380693364..6cb2dbd2b0f 100644
--- a/lucene/queries/src/java/org/apache/lucene/queries/payloads/SpanPayloadCheckQuery.java
+++ b/lucene/queries/src/java/org/apache/lucene/queries/payloads/SpanPayloadCheckQuery.java
@@ -192,7 +192,7 @@ public class SpanPayloadCheckQuery extends SpanQuery {
return null;
}
final LeafSimScorer docScorer = getSimScorer(context);
- final var scorer = new SpanScorer(this, spans, docScorer);
+ final var scorer = new SpanScorer(spans, docScorer);
return new DefaultScorerSupplier(scorer);
}
diff --git a/lucene/queries/src/java/org/apache/lucene/queries/spans/SpanContainingQuery.java b/lucene/queries/src/java/org/apache/lucene/queries/spans/SpanContainingQuery.java
index 4ac22673420..4752d6bee38 100644
--- a/lucene/queries/src/java/org/apache/lucene/queries/spans/SpanContainingQuery.java
+++ b/lucene/queries/src/java/org/apache/lucene/queries/spans/SpanContainingQuery.java
@@ -140,13 +140,12 @@ public final class SpanContainingQuery extends SpanContainQuery {
@Override
public ScorerSupplier scorerSupplier(LeafReaderContext context) throws IOException {
- final SpanWeight spanWeight = this;
final Spans spans = getSpans(context, Postings.POSITIONS);
if (spans == null) {
return null;
}
final LeafSimScorer docScorer = getSimScorer(context);
- final var scorer = new SpanScorer(spanWeight, spans, docScorer);
+ final var scorer = new SpanScorer(spans, docScorer);
return new DefaultScorerSupplier(scorer);
}
}
diff --git a/lucene/queries/src/java/org/apache/lucene/queries/spans/SpanNearQuery.java b/lucene/queries/src/java/org/apache/lucene/queries/spans/SpanNearQuery.java
index ca97ffef0dc..69e1a74c80b 100644
--- a/lucene/queries/src/java/org/apache/lucene/queries/spans/SpanNearQuery.java
+++ b/lucene/queries/src/java/org/apache/lucene/queries/spans/SpanNearQuery.java
@@ -243,13 +243,12 @@ public class SpanNearQuery extends SpanQuery implements Cloneable {
@Override
public ScorerSupplier scorerSupplier(LeafReaderContext context) throws IOException {
- final SpanWeight spanWeight = this;
final Spans spans = getSpans(context, Postings.POSITIONS);
if (spans == null) {
return null;
}
final LeafSimScorer docScorer = getSimScorer(context);
- final var scorer = new SpanScorer(spanWeight, spans, docScorer);
+ final var scorer = new SpanScorer(spans, docScorer);
return new DefaultScorerSupplier(scorer);
}
}
diff --git a/lucene/queries/src/java/org/apache/lucene/queries/spans/SpanScorer.java b/lucene/queries/src/java/org/apache/lucene/queries/spans/SpanScorer.java
index cb293272cfe..9737ae5308e 100644
--- a/lucene/queries/src/java/org/apache/lucene/queries/spans/SpanScorer.java
+++ b/lucene/queries/src/java/org/apache/lucene/queries/spans/SpanScorer.java
@@ -39,8 +39,7 @@ public class SpanScorer extends Scorer {
private int lastScoredDoc = -1; // last doc we called setFreqCurrentDoc() for
/** Sole constructor. */
- public SpanScorer(SpanWeight weight, Spans spans, LeafSimScorer docScorer) {
- super(weight);
+ public SpanScorer(Spans spans, LeafSimScorer docScorer) {
this.spans = Objects.requireNonNull(spans);
this.docScorer = docScorer;
}
diff --git a/lucene/queries/src/java/org/apache/lucene/queries/spans/SpanWeight.java b/lucene/queries/src/java/org/apache/lucene/queries/spans/SpanWeight.java
index b8b2f812e4b..29e1c13e773 100644
--- a/lucene/queries/src/java/org/apache/lucene/queries/spans/SpanWeight.java
+++ b/lucene/queries/src/java/org/apache/lucene/queries/spans/SpanWeight.java
@@ -143,7 +143,7 @@ public abstract class SpanWeight extends Weight {
return null;
}
final LeafSimScorer docScorer = getSimScorer(context);
- final var scorer = new SpanScorer(this, spans, docScorer);
+ final var scorer = new SpanScorer(spans, docScorer);
return new ScorerSupplier() {
@Override
public SpanScorer get(long leadCost) throws IOException {
diff --git a/lucene/queries/src/test/org/apache/lucene/queries/function/TestSortedSetFieldSource.java b/lucene/queries/src/test/org/apache/lucene/queries/function/TestSortedSetFieldSource.java
index 3245ec8d40f..05a946298d3 100644
--- a/lucene/queries/src/test/org/apache/lucene/queries/function/TestSortedSetFieldSource.java
+++ b/lucene/queries/src/test/org/apache/lucene/queries/function/TestSortedSetFieldSource.java
@@ -28,8 +28,6 @@ import org.apache.lucene.index.NoMergePolicy;
import org.apache.lucene.queries.function.valuesource.SortedSetFieldSource;
import org.apache.lucene.search.DocIdSetIterator;
import org.apache.lucene.search.IndexSearcher;
-import org.apache.lucene.search.MatchAllDocsQuery;
-import org.apache.lucene.search.ScoreMode;
import org.apache.lucene.search.SortField;
import org.apache.lucene.search.SortedSetSortField;
import org.apache.lucene.store.Directory;
@@ -77,14 +75,7 @@ public class TestSortedSetFieldSource extends LuceneTestCase {
// test scorer
vs = new SortedSetFieldSource("value");
values = vs.getValues(Collections.emptyMap(), ar.getContext());
- ValueSourceScorer vss =
- values.getRangeScorer(
- new MatchAllDocsQuery().createWeight(searcher, ScoreMode.TOP_SCORES, 1),
- ar.getContext(),
- "a",
- "z",
- true,
- true);
+ ValueSourceScorer vss = values.getRangeScorer(ar.getContext(), "a", "z", true, true);
DocIdSetIterator iterator = vss.iterator();
assertEquals("baz", values.strVal(iterator.nextDoc()));
diff --git a/lucene/sandbox/src/java/org/apache/lucene/sandbox/search/CombinedFieldQuery.java b/lucene/sandbox/src/java/org/apache/lucene/sandbox/search/CombinedFieldQuery.java
index 28a0391563e..9fe6b890044 100644
--- a/lucene/sandbox/src/java/org/apache/lucene/sandbox/search/CombinedFieldQuery.java
+++ b/lucene/sandbox/src/java/org/apache/lucene/sandbox/search/CombinedFieldQuery.java
@@ -428,13 +428,12 @@ public final class CombinedFieldQuery extends Query implements Accountable {
for (int i = 0; i < iterators.size(); i++) {
float weight = fields.get(i).weight;
queue.add(
- new WeightedDisiWrapper(
- new TermScorer(this, iterators.get(i), nonScoringSimScorer), weight));
+ new WeightedDisiWrapper(new TermScorer(iterators.get(i), nonScoringSimScorer), weight));
}
// Even though it is called approximation, it is accurate since none of
// the sub iterators are two-phase iterators.
DocIdSetIterator iterator = new DisjunctionDISIApproximation(queue);
- final var scorer = new CombinedFieldScorer(this, queue, iterator, scoringSimScorer);
+ final var scorer = new CombinedFieldScorer(queue, iterator, scoringSimScorer);
return new DefaultScorerSupplier(scorer);
}
@@ -463,11 +462,7 @@ public final class CombinedFieldQuery extends Query implements Accountable {
private final MultiNormsLeafSimScorer simScorer;
CombinedFieldScorer(
- Weight weight,
- DisiPriorityQueue queue,
- DocIdSetIterator iterator,
- MultiNormsLeafSimScorer simScorer) {
- super(weight);
+ DisiPriorityQueue queue, DocIdSetIterator iterator, MultiNormsLeafSimScorer simScorer) {
this.queue = queue;
this.iterator = iterator;
this.simScorer = simScorer;
diff --git a/lucene/sandbox/src/java/org/apache/lucene/sandbox/search/CoveringQuery.java b/lucene/sandbox/src/java/org/apache/lucene/sandbox/search/CoveringQuery.java
index 26b54de1d25..2e71813620a 100644
--- a/lucene/sandbox/src/java/org/apache/lucene/sandbox/search/CoveringQuery.java
+++ b/lucene/sandbox/src/java/org/apache/lucene/sandbox/search/CoveringQuery.java
@@ -248,10 +248,7 @@ public final class CoveringQuery extends Query implements Accountable {
}
final var scorer =
new CoveringScorer(
- this,
- scorers,
- minimumNumberMatch.getValues(context, null),
- context.reader().maxDoc());
+ scorers, minimumNumberMatch.getValues(context, null), context.reader().maxDoc());
return new DefaultScorerSupplier(scorer);
}
diff --git a/lucene/sandbox/src/java/org/apache/lucene/sandbox/search/CoveringScorer.java b/lucene/sandbox/src/java/org/apache/lucene/sandbox/search/CoveringScorer.java
index 49081d2412c..a4662b2c679 100644
--- a/lucene/sandbox/src/java/org/apache/lucene/sandbox/search/CoveringScorer.java
+++ b/lucene/sandbox/src/java/org/apache/lucene/sandbox/search/CoveringScorer.java
@@ -26,7 +26,6 @@ import org.apache.lucene.search.DocIdSetIterator;
import org.apache.lucene.search.LongValues;
import org.apache.lucene.search.Scorer;
import org.apache.lucene.search.TwoPhaseIterator;
-import org.apache.lucene.search.Weight;
/** A {@link Scorer} whose number of matches is per-document. */
final class CoveringScorer extends Scorer {
@@ -46,9 +45,7 @@ final class CoveringScorer extends Scorer {
final long cost;
- CoveringScorer(Weight weight, Collection<Scorer> scorers, LongValues minMatchValues, int maxDoc) {
- super(weight);
-
+ CoveringScorer(Collection<Scorer> scorers, LongValues minMatchValues, int maxDoc) {
this.numScorers = scorers.size();
this.maxDoc = maxDoc;
this.minMatchValues = minMatchValues;
diff --git a/lucene/sandbox/src/java/org/apache/lucene/sandbox/search/MultiRangeQuery.java b/lucene/sandbox/src/java/org/apache/lucene/sandbox/search/MultiRangeQuery.java
index ee1f0b2b8d6..66c490b791a 100644
--- a/lucene/sandbox/src/java/org/apache/lucene/sandbox/search/MultiRangeQuery.java
+++ b/lucene/sandbox/src/java/org/apache/lucene/sandbox/search/MultiRangeQuery.java
@@ -333,14 +333,13 @@ public abstract class MultiRangeQuery extends Query implements Cloneable {
allDocsMatch = false;
}
- final Weight weight = this;
if (allDocsMatch) {
// all docs have a value and all points are within bounds, so everything matches
return new ScorerSupplier() {
@Override
public Scorer get(long leadCost) {
return new ConstantScoreScorer(
- weight, score(), scoreMode, DocIdSetIterator.all(reader.maxDoc()));
+ score(), scoreMode, DocIdSetIterator.all(reader.maxDoc()));
}
@Override
@@ -359,7 +358,7 @@ public abstract class MultiRangeQuery extends Query implements Cloneable {
public Scorer get(long leadCost) throws IOException {
values.intersect(visitor);
DocIdSetIterator iterator = result.build().iterator();
- return new ConstantScoreScorer(weight, score(), scoreMode, iterator);
+ return new ConstantScoreScorer(score(), scoreMode, iterator);
}
@Override
diff --git a/lucene/sandbox/src/java/org/apache/lucene/sandbox/search/QueryProfilerScorer.java b/lucene/sandbox/src/java/org/apache/lucene/sandbox/search/QueryProfilerScorer.java
index d99b5716827..a809899f20a 100644
--- a/lucene/sandbox/src/java/org/apache/lucene/sandbox/search/QueryProfilerScorer.java
+++ b/lucene/sandbox/src/java/org/apache/lucene/sandbox/search/QueryProfilerScorer.java
@@ -22,7 +22,6 @@ import java.util.Collection;
import org.apache.lucene.search.DocIdSetIterator;
import org.apache.lucene.search.Scorer;
import org.apache.lucene.search.TwoPhaseIterator;
-import org.apache.lucene.search.Weight;
/**
* {@link Scorer} wrapper that will compute how much time is spent on moving the iterator,
@@ -31,8 +30,6 @@ import org.apache.lucene.search.Weight;
class QueryProfilerScorer extends Scorer {
private final Scorer scorer;
- private final QueryProfilerWeight profileWeight;
-
private final QueryProfilerTimer scoreTimer,
nextDocTimer,
advanceTimer,
@@ -41,10 +38,8 @@ class QueryProfilerScorer extends Scorer {
computeMaxScoreTimer,
setMinCompetitiveScoreTimer;
- QueryProfilerScorer(QueryProfilerWeight w, Scorer scorer, QueryProfilerBreakdown profile) {
- super(w);
+ QueryProfilerScorer(Scorer scorer, QueryProfilerBreakdown profile) {
this.scorer = scorer;
- this.profileWeight = w;
scoreTimer = profile.getTimer(QueryProfilerTimingType.SCORE);
nextDocTimer = profile.getTimer(QueryProfilerTimingType.NEXT_DOC);
advanceTimer = profile.getTimer(QueryProfilerTimingType.ADVANCE);
@@ -70,11 +65,6 @@ class QueryProfilerScorer extends Scorer {
}
}
- @Override
- public Weight getWeight() {
- return profileWeight;
- }
-
@Override
public Collection<ChildScorable> getChildren() throws IOException {
return scorer.getChildren();
diff --git a/lucene/sandbox/src/java/org/apache/lucene/sandbox/search/QueryProfilerWeight.java b/lucene/sandbox/src/java/org/apache/lucene/sandbox/search/QueryProfilerWeight.java
index 77113cd181a..dbc9816ef18 100644
--- a/lucene/sandbox/src/java/org/apache/lucene/sandbox/search/QueryProfilerWeight.java
+++ b/lucene/sandbox/src/java/org/apache/lucene/sandbox/search/QueryProfilerWeight.java
@@ -62,15 +62,13 @@ class QueryProfilerWeight extends FilterWeight {
if (subQueryScorerSupplier == null) {
return null;
}
-
- final QueryProfilerWeight weight = this;
return new ScorerSupplier() {
@Override
public Scorer get(long loadCost) throws IOException {
timer.start();
try {
- return new QueryProfilerScorer(weight, subQueryScorerSupplier.get(loadCost), profile);
+ return new QueryProfilerScorer(subQueryScorerSupplier.get(loadCost), profile);
} finally {
timer.stop();
}
diff --git a/lucene/sandbox/src/java/org/apache/lucene/sandbox/search/TermAutomatonScorer.java b/lucene/sandbox/src/java/org/apache/lucene/sandbox/search/TermAutomatonScorer.java
index 5a44190d1d7..2d0b7ecb85b 100644
--- a/lucene/sandbox/src/java/org/apache/lucene/sandbox/search/TermAutomatonScorer.java
+++ b/lucene/sandbox/src/java/org/apache/lucene/sandbox/search/TermAutomatonScorer.java
@@ -63,7 +63,6 @@ class TermAutomatonScorer extends Scorer {
public TermAutomatonScorer(
TermAutomatonWeight weight, EnumAndScorer[] subs, int anyTermID, LeafSimScorer docScorer)
throws IOException {
- super(weight);
// System.out.println(" automaton:\n" + weight.automaton.toDot());
this.runAutomaton = new TermRunAutomaton(weight.automaton, subs.length);
this.docScorer = docScorer;
@@ -361,11 +360,6 @@ class TermAutomatonScorer extends Scorer {
return docScorer;
}
- @Override
- public String toString() {
- return "TermAutomatonScorer(" + weight + ")";
- }
-
@Override
public int docID() {
return docID;
diff --git a/lucene/sandbox/src/test/org/apache/lucene/sandbox/search/TestQueryProfilerScorer.java b/lucene/sandbox/src/test/org/apache/lucene/sandbox/search/TestQueryProfilerScorer.java
index 06910995977..add8db29d3d 100644
--- a/lucene/sandbox/src/test/org/apache/lucene/sandbox/search/TestQueryProfilerScorer.java
+++ b/lucene/sandbox/src/test/org/apache/lucene/sandbox/search/TestQueryProfilerScorer.java
@@ -18,14 +18,8 @@
package org.apache.lucene.sandbox.search;
import java.io.IOException;
-import org.apache.lucene.index.MultiReader;
import org.apache.lucene.search.DocIdSetIterator;
-import org.apache.lucene.search.IndexSearcher;
-import org.apache.lucene.search.MatchAllDocsQuery;
-import org.apache.lucene.search.Query;
-import org.apache.lucene.search.ScoreMode;
import org.apache.lucene.search.Scorer;
-import org.apache.lucene.search.Weight;
import org.apache.lucene.tests.util.LuceneTestCase;
public class TestQueryProfilerScorer extends LuceneTestCase {
@@ -34,9 +28,7 @@ public class TestQueryProfilerScorer extends LuceneTestCase {
public float maxScore, minCompetitiveScore;
- protected FakeScorer(Weight weight) {
- super(weight);
- }
+ protected FakeScorer() {}
@Override
public DocIdSetIterator iterator() {
@@ -65,27 +57,17 @@ public class TestQueryProfilerScorer extends LuceneTestCase {
}
public void testPropagateMinCompetitiveScore() throws IOException {
- Query query = new MatchAllDocsQuery();
- Weight weight =
- query.createWeight(new IndexSearcher(new MultiReader()), ScoreMode.TOP_SCORES, 1f);
- FakeScorer fakeScorer = new FakeScorer(weight);
+ FakeScorer fakeScorer = new FakeScorer();
QueryProfilerBreakdown profile = new QueryProfilerBreakdown();
- QueryProfilerWeight queryProfilerWeight = new QueryProfilerWeight(weight, profile);
- QueryProfilerScorer queryProfilerScorer =
- new QueryProfilerScorer(queryProfilerWeight, fakeScorer, profile);
+ QueryProfilerScorer queryProfilerScorer = new QueryProfilerScorer(fakeScorer, profile);
queryProfilerScorer.setMinCompetitiveScore(0.42f);
assertEquals(0.42f, fakeScorer.minCompetitiveScore, 0f);
}
public void testPropagateMaxScore() throws IOException {
- Query query = new MatchAllDocsQuery();
- Weight weight =
- query.createWeight(new IndexSearcher(new MultiReader()), ScoreMode.TOP_SCORES, 1f);
- FakeScorer fakeScorer = new FakeScorer(weight);
+ FakeScorer fakeScorer = new FakeScorer();
QueryProfilerBreakdown profile = new QueryProfilerBreakdown();
- QueryProfilerWeight queryProfilerWeight = new QueryProfilerWeight(weight, profile);
- QueryProfilerScorer queryProfilerScorer =
- new QueryProfilerScorer(queryProfilerWeight, fakeScorer, profile);
+ QueryProfilerScorer queryProfilerScorer = new QueryProfilerScorer(fakeScorer, profile);
queryProfilerScorer.setMinCompetitiveScore(0.42f);
fakeScorer.maxScore = 42f;
assertEquals(42f, queryProfilerScorer.getMaxScore(DocIdSetIterator.NO_MORE_DOCS), 0f);
diff --git a/lucene/sandbox/src/test/org/apache/lucene/sandbox/search/TestQueryProfilerWeight.java b/lucene/sandbox/src/test/org/apache/lucene/sandbox/search/TestQueryProfilerWeight.java
index 584fb364f1c..41dc054a075 100644
--- a/lucene/sandbox/src/test/org/apache/lucene/sandbox/search/TestQueryProfilerWeight.java
+++ b/lucene/sandbox/src/test/org/apache/lucene/sandbox/search/TestQueryProfilerWeight.java
@@ -47,13 +47,12 @@ public class TestQueryProfilerWeight extends LuceneTestCase {
@Override
public ScorerSupplier scorerSupplier(LeafReaderContext context) {
- Weight weight = this;
return new ScorerSupplier() {
private long cost = 0;
@Override
public Scorer get(long leadCost) {
- return new Scorer(weight) {
+ return new Scorer() {
@Override
public DocIdSetIterator iterator() {
return null;
diff --git a/lucene/sandbox/src/test/org/apache/lucene/sandbox/search/TestTermAutomatonQuery.java b/lucene/sandbox/src/test/org/apache/lucene/sandbox/search/TestTermAutomatonQuery.java
index 33d7bf829b8..937bad87b43 100644
--- a/lucene/sandbox/src/test/org/apache/lucene/sandbox/search/TestTermAutomatonQuery.java
+++ b/lucene/sandbox/src/test/org/apache/lucene/sandbox/search/TestTermAutomatonQuery.java
@@ -609,10 +609,7 @@ public class TestTermAutomatonQuery extends LuceneTestCase {
}
final var scorer =
new ConstantScoreScorer(
- this,
- score(),
- scoreMode,
- new BitSetIterator(bits, bits.approximateCardinality()));
+ score(), scoreMode, new BitSetIterator(bits, bits.approximateCardinality()));
return new DefaultScorerSupplier(scorer);
}
diff --git a/lucene/spatial-extras/src/java/org/apache/lucene/spatial/composite/CompositeVerifyQuery.java b/lucene/spatial-extras/src/java/org/apache/lucene/spatial/composite/CompositeVerifyQuery.java
index 98efed7b996..b28c47c94c3 100644
--- a/lucene/spatial-extras/src/java/org/apache/lucene/spatial/composite/CompositeVerifyQuery.java
+++ b/lucene/spatial-extras/src/java/org/apache/lucene/spatial/composite/CompositeVerifyQuery.java
@@ -106,7 +106,7 @@ public class CompositeVerifyQuery extends Query {
final TwoPhaseIterator predFuncValues =
predicateValueSource.iterator(context, indexQueryScorer.iterator());
- final var scorer = new ConstantScoreScorer(this, score(), scoreMode, predFuncValues);
+ final var scorer = new ConstantScoreScorer(score(), scoreMode, predFuncValues);
return new DefaultScorerSupplier(scorer);
}
diff --git a/lucene/spatial-extras/src/java/org/apache/lucene/spatial/composite/IntersectsRPTVerifyQuery.java b/lucene/spatial-extras/src/java/org/apache/lucene/spatial/composite/IntersectsRPTVerifyQuery.java
index 90bbd91c551..559a946d096 100644
--- a/lucene/spatial-extras/src/java/org/apache/lucene/spatial/composite/IntersectsRPTVerifyQuery.java
+++ b/lucene/spatial-extras/src/java/org/apache/lucene/spatial/composite/IntersectsRPTVerifyQuery.java
@@ -113,7 +113,7 @@ public class IntersectsRPTVerifyQuery extends Query {
// If both sets are the same, there's nothing to verify; we needn't return a
// TwoPhaseIterator
if (result.approxDocIdSet == result.exactDocIdSet) {
- s = new ConstantScoreScorer(this, score(), scoreMode, approxDISI);
+ s = new ConstantScoreScorer(score(), scoreMode, approxDISI);
}
exactIterator = result.exactDocIdSet.iterator();
assert exactIterator != null;
@@ -148,7 +148,7 @@ public class IntersectsRPTVerifyQuery extends Query {
}
};
- s = new ConstantScoreScorer(this, score(), scoreMode, twoPhaseIterator);
+ s = new ConstantScoreScorer(score(), scoreMode, twoPhaseIterator);
final Scorer scorer = s;
return new DefaultScorerSupplier(scorer);
}
diff --git a/lucene/spatial-extras/src/java/org/apache/lucene/spatial/prefix/AbstractPrefixTreeQuery.java b/lucene/spatial-extras/src/java/org/apache/lucene/spatial/prefix/AbstractPrefixTreeQuery.java
index 2877e8b04bb..cb1195d1803 100644
--- a/lucene/spatial-extras/src/java/org/apache/lucene/spatial/prefix/AbstractPrefixTreeQuery.java
+++ b/lucene/spatial-extras/src/java/org/apache/lucene/spatial/prefix/AbstractPrefixTreeQuery.java
@@ -99,7 +99,7 @@ public abstract class AbstractPrefixTreeQuery extends Query {
if (disi == null) {
return null;
}
- final var scorer = new ConstantScoreScorer(this, score(), scoreMode, disi);
+ final var scorer = new ConstantScoreScorer(score(), scoreMode, disi);
return new DefaultScorerSupplier(scorer);
}
diff --git a/lucene/spatial-extras/src/java/org/apache/lucene/spatial/serialized/SerializedDVStrategy.java b/lucene/spatial-extras/src/java/org/apache/lucene/spatial/serialized/SerializedDVStrategy.java
index 05686569a7a..5074b1ba47c 100644
--- a/lucene/spatial-extras/src/java/org/apache/lucene/spatial/serialized/SerializedDVStrategy.java
+++ b/lucene/spatial-extras/src/java/org/apache/lucene/spatial/serialized/SerializedDVStrategy.java
@@ -137,7 +137,7 @@ public class SerializedDVStrategy extends SpatialStrategy {
public ScorerSupplier scorerSupplier(LeafReaderContext context) throws IOException {
DocIdSetIterator approximation = DocIdSetIterator.all(context.reader().maxDoc());
TwoPhaseIterator it = predicateValueSource.iterator(context, approximation);
- final var scorer = new ConstantScoreScorer(this, score(), scoreMode, it);
+ final var scorer = new ConstantScoreScorer(score(), scoreMode, it);
return new DefaultScorerSupplier(scorer);
}
diff --git a/lucene/spatial-extras/src/java/org/apache/lucene/spatial/vector/PointVectorStrategy.java b/lucene/spatial-extras/src/java/org/apache/lucene/spatial/vector/PointVectorStrategy.java
index d3ba8434e75..13b9c10f18a 100644
--- a/lucene/spatial-extras/src/java/org/apache/lucene/spatial/vector/PointVectorStrategy.java
+++ b/lucene/spatial-extras/src/java/org/apache/lucene/spatial/vector/PointVectorStrategy.java
@@ -287,7 +287,7 @@ public class PointVectorStrategy extends SpatialStrategy {
return 100; // distance calculation can be heavy!
}
};
- final var scorer = new ConstantScoreScorer(this, score(), scoreMode, twoPhase);
+ final var scorer = new ConstantScoreScorer(score(), scoreMode, twoPhase);
return new DefaultScorerSupplier(scorer);
}
diff --git a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/PointInGeo3DShapeQuery.java b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/PointInGeo3DShapeQuery.java
index 399db5da4ed..c7ee8877dfb 100644
--- a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/PointInGeo3DShapeQuery.java
+++ b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/PointInGeo3DShapeQuery.java
@@ -106,8 +106,7 @@ final class PointInGeo3DShapeQuery extends Query implements Accountable {
values.intersect(new PointInShapeIntersectVisitor(result, shape, shapeBounds));
- final var scorer =
- new ConstantScoreScorer(this, score(), scoreMode, result.build().iterator());
+ final var scorer = new ConstantScoreScorer(score(), scoreMode, result.build().iterator());
return new DefaultScorerSupplier(scorer);
}
diff --git a/lucene/test-framework/src/java/org/apache/lucene/tests/search/AssertingScorer.java b/lucene/test-framework/src/java/org/apache/lucene/tests/search/AssertingScorer.java
index a68ca05400a..8badba0d12b 100644
--- a/lucene/test-framework/src/java/org/apache/lucene/tests/search/AssertingScorer.java
+++ b/lucene/test-framework/src/java/org/apache/lucene/tests/search/AssertingScorer.java
@@ -55,7 +55,6 @@ public class AssertingScorer extends Scorer {
private AssertingScorer(
Random random, Scorer in, ScoreMode scoreMode, boolean canCallMinCompetitiveScore) {
- super(in.getWeight());
this.random = random;
this.in = in;
this.scoreMode = scoreMode;
diff --git a/lucene/test-framework/src/java/org/apache/lucene/tests/search/BlockScoreQueryWrapper.java b/lucene/test-framework/src/java/org/apache/lucene/tests/search/BlockScoreQueryWrapper.java
index f56473d807b..39e78e38964 100644
--- a/lucene/test-framework/src/java/org/apache/lucene/tests/search/BlockScoreQueryWrapper.java
+++ b/lucene/test-framework/src/java/org/apache/lucene/tests/search/BlockScoreQueryWrapper.java
@@ -122,7 +122,7 @@ public final class BlockScoreQueryWrapper extends Query {
final float[] scores = ArrayUtil.copyOfSubArray(tmpScores, 0, i);
final var scorer =
- new Scorer(inWeight) {
+ new Scorer() {
int i = 0;
diff --git a/lucene/test-framework/src/java/org/apache/lucene/tests/search/BulkScorerWrapperScorer.java b/lucene/test-framework/src/java/org/apache/lucene/tests/search/BulkScorerWrapperScorer.java
index e7476ecdcb8..d5fb7ed719c 100644
--- a/lucene/test-framework/src/java/org/apache/lucene/tests/search/BulkScorerWrapperScorer.java
+++ b/lucene/test-framework/src/java/org/apache/lucene/tests/search/BulkScorerWrapperScorer.java
@@ -23,7 +23,6 @@ import org.apache.lucene.search.DocIdSetIterator;
import org.apache.lucene.search.LeafCollector;
import org.apache.lucene.search.Scorable;
import org.apache.lucene.search.Scorer;
-import org.apache.lucene.search.Weight;
/** A {@link BulkScorer}-backed scorer. */
public class BulkScorerWrapperScorer extends Scorer {
@@ -39,8 +38,7 @@ public class BulkScorerWrapperScorer extends Scorer {
private int bufferLength;
/** Sole constructor. */
- public BulkScorerWrapperScorer(Weight weight, BulkScorer scorer, int bufferSize) {
- super(weight);
+ public BulkScorerWrapperScorer(BulkScorer scorer, int bufferSize) {
this.scorer = scorer;
docs = new int[bufferSize];
scores = new float[bufferSize];
diff --git a/lucene/test-framework/src/java/org/apache/lucene/tests/search/RandomApproximationQuery.java b/lucene/test-framework/src/java/org/apache/lucene/tests/search/RandomApproximationQuery.java
index 73adcb5e95e..11e7d704b69 100644
--- a/lucene/test-framework/src/java/org/apache/lucene/tests/search/RandomApproximationQuery.java
+++ b/lucene/test-framework/src/java/org/apache/lucene/tests/search/RandomApproximationQuery.java
@@ -107,7 +107,6 @@ public class RandomApproximationQuery extends Query {
private final RandomTwoPhaseView twoPhaseView;
RandomApproximationScorer(Scorer scorer, Random random) {
- super(scorer.getWeight());
this.scorer = scorer;
this.twoPhaseView = new RandomTwoPhaseView(random, scorer.iterator());
}
diff --git a/lucene/test-framework/src/java/org/apache/lucene/tests/search/ScorerIndexSearcher.java b/lucene/test-framework/src/java/org/apache/lucene/tests/search/ScorerIndexSearcher.java
index d3a414bc988..139c7a421c9 100644
--- a/lucene/test-framework/src/java/org/apache/lucene/tests/search/ScorerIndexSearcher.java
+++ b/lucene/test-framework/src/java/org/apache/lucene/tests/search/ScorerIndexSearcher.java
@@ -55,6 +55,7 @@ public class ScorerIndexSearcher extends IndexSearcher {
@Override
protected void search(List<LeafReaderContext> leaves, Weight weight, Collector collector)
throws IOException {
+ collector.setWeight(weight);
for (LeafReaderContext ctx : leaves) { // search each subreader
// we force the use of Scorer (not BulkScorer) to make sure
// that the scorer passed to LeafCollector.setScorer supports