Skip to content

Apache Lucene open-source search software

LUCENE-6761: MatchAllDocsQuery's Scorers do not expose approximations anymore.

Adrien Grand3bab6026b13a
diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt
index 00ed921d8f2..407b64ab0a5 100644
--- a/lucene/CHANGES.txt
+++ b/lucene/CHANGES.txt
@@ -119,6 +119,9 @@ Other
* LUCENE-6768: AbstractFirstPassGroupingCollector.groupSort private member
is not needed. (Christine Poerschke)
+* LUCENE-6761: MatchAllDocsQuery's Scorers do not expose approximations
+ anymore. (Adrien Grand)
+
Build
* LUCENE-6732: Improve checker for invalid source patterns to also
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 d528b36b1b2..e67a95ea6e5 100644
--- a/lucene/core/src/java/org/apache/lucene/search/MatchAllDocsQuery.java
+++ b/lucene/core/src/java/org/apache/lucene/search/MatchAllDocsQuery.java
@@ -31,16 +31,16 @@ public final class MatchAllDocsQuery extends Query {
@Override
public Weight createWeight(IndexSearcher searcher, boolean needsScores) {
- return new RandomAccessWeight(this) {
- @Override
- protected Bits getMatchingDocs(LeafReaderContext context) throws IOException {
- return new Bits.MatchAllBits(context.reader().maxDoc());
- }
+ return new ConstantScoreWeight(this) {
@Override
public String toString() {
return "weight(" + MatchAllDocsQuery.this + ")";
}
@Override
+ public Scorer scorer(LeafReaderContext context) throws IOException {
+ return new ConstantScoreScorer(this, score(), DocIdSetIterator.all(context.reader().maxDoc()));
+ }
+ @Override
public BulkScorer bulkScorer(LeafReaderContext context) throws IOException {
final float score = score();
final int maxDoc = context.reader().maxDoc();