From 3bab6026b13af497103dd25c8032d6db726c3381 Mon Sep 17 00:00:00 2001 From: Adrien Grand Date: Wed, 2 Sep 2015 10:18:35 +0000 Subject: [PATCH] LUCENE-6761: MatchAllDocsQuery's Scorers do not expose approximations anymore. git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1700754 13f79535-47bb-0310-9956-ffa450edef68 --- lucene/CHANGES.txt | 3 +++ .../org/apache/lucene/search/MatchAllDocsQuery.java | 10 +++++----- 2 files changed, 8 insertions(+), 5 deletions(-) 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();