You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by jp...@apache.org on 2015/02/21 15:40:12 UTC
svn commit: r1661371 - in /lucene/dev/branches/branch_5x: ./ lucene/
lucene/CHANGES.txt lucene/core/
lucene/core/src/java/org/apache/lucene/search/ConstantScoreQuery.java
lucene/core/src/test/org/apache/lucene/search/TestConstantScoreQuery.java
Author: jpountz
Date: Sat Feb 21 14:40:11 2015
New Revision: 1661371
URL: http://svn.apache.org/r1661371
Log:
LUCENE-6262: Don't wrap the inner weight in ConstantScoreQuery when scores are not required.
Modified:
lucene/dev/branches/branch_5x/ (props changed)
lucene/dev/branches/branch_5x/lucene/ (props changed)
lucene/dev/branches/branch_5x/lucene/CHANGES.txt (contents, props changed)
lucene/dev/branches/branch_5x/lucene/core/ (props changed)
lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/ConstantScoreQuery.java
lucene/dev/branches/branch_5x/lucene/core/src/test/org/apache/lucene/search/TestConstantScoreQuery.java
Modified: lucene/dev/branches/branch_5x/lucene/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/CHANGES.txt?rev=1661371&r1=1661370&r2=1661371&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/CHANGES.txt (original)
+++ lucene/dev/branches/branch_5x/lucene/CHANGES.txt Sat Feb 21 14:40:11 2015
@@ -66,6 +66,9 @@ Optimizations
filter out non-index files with some custom usage, you may want to look at
the IndexFileNames class. (Robert Muir)
+* LUCENE-6262: ConstantScoreQuery does not wrap the inner weight anymore when
+ scores are not required. (Adrien Grand)
+
API Changes
* LUCENE-6204, LUCENE-6208: Simplify CompoundFormat: remove files()
Modified: lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/ConstantScoreQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/ConstantScoreQuery.java?rev=1661371&r1=1661370&r2=1661371&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/ConstantScoreQuery.java (original)
+++ lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/ConstantScoreQuery.java Sat Feb 21 14:40:11 2015
@@ -78,9 +78,9 @@ public class ConstantScoreQuery extends
private float queryNorm;
private float queryWeight;
- public ConstantWeight(IndexSearcher searcher) throws IOException {
+ public ConstantWeight(Weight innerWeight) throws IOException {
super(ConstantScoreQuery.this);
- this.innerWeight = query.createWeight(searcher, false);
+ this.innerWeight = innerWeight;
}
@Override
@@ -277,7 +277,12 @@ public class ConstantScoreQuery extends
@Override
public Weight createWeight(IndexSearcher searcher, boolean needsScores) throws IOException {
- return new ConstantScoreQuery.ConstantWeight(searcher);
+ final Weight innerWeight = query.createWeight(searcher, false);
+ if (needsScores) {
+ return new ConstantScoreQuery.ConstantWeight(innerWeight);
+ } else {
+ return innerWeight;
+ }
}
@Override
Modified: lucene/dev/branches/branch_5x/lucene/core/src/test/org/apache/lucene/search/TestConstantScoreQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/core/src/test/org/apache/lucene/search/TestConstantScoreQuery.java?rev=1661371&r1=1661370&r2=1661371&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/core/src/test/org/apache/lucene/search/TestConstantScoreQuery.java (original)
+++ lucene/dev/branches/branch_5x/lucene/core/src/test/org/apache/lucene/search/TestConstantScoreQuery.java Sat Feb 21 14:40:11 2015
@@ -115,8 +115,8 @@ public class TestConstantScoreQuery exte
final Query csqbq = new ConstantScoreQuery(bq);
csqbq.setBoost(17.0f);
- checkHits(searcher, csq1, csq1.getBoost(), ConstantScoreQuery.ConstantScoreScorer.class.getName(), null);
- checkHits(searcher, csq2, csq2.getBoost(), ConstantScoreQuery.ConstantScoreScorer.class.getName(), ConstantScoreQuery.ConstantScoreScorer.class.getName());
+ checkHits(searcher, csq1, csq1.getBoost(), ConstantScoreQuery.ConstantScoreScorer.class.getName(), TermScorer.class.getName());
+ checkHits(searcher, csq2, csq2.getBoost(), ConstantScoreQuery.ConstantScoreScorer.class.getName(), TermScorer.class.getName());
// for the combined BQ, the scorer should always be BooleanScorer's BucketScorer, because our scorer supports out-of order collection!
final String bucketScorerClass = FakeScorer.class.getName();