diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt index 1feade26c92..857aa4009a4 100644 --- a/lucene/CHANGES.txt +++ b/lucene/CHANGES.txt @@ -656,6 +656,9 @@ Optimizations * LUCENE-3426: Add NGramPhraseQuery which extends PhraseQuery and tries to reduce the number of terms of the query when rewrite(), in order to improve performance. (Robert Muir, Koji Sekiguchi) + +* LUCENE-3494: Optimize FilteredQuery to remove a multiply in score() + (Uwe Schindler, Robert Muir) Test Cases diff --git a/lucene/src/java/org/apache/lucene/search/FilteredQuery.java b/lucene/src/java/org/apache/lucene/search/FilteredQuery.java index a9c9eea55b2..2a007c00c2c 100644 --- a/lucene/src/java/org/apache/lucene/search/FilteredQuery.java +++ b/lucene/src/java/org/apache/lucene/search/FilteredQuery.java @@ -67,23 +67,17 @@ extends Query { @Override public float getValueForNormalization() throws IOException { - return weight.getValueForNormalization() * getBoost() * getBoost(); + return weight.getValueForNormalization() * getBoost() * getBoost(); // boost sub-weight } @Override public void normalize (float norm, float topLevelBoost) { - weight.normalize(norm, topLevelBoost); + weight.normalize(norm, topLevelBoost * getBoost()); // incorporate boost } @Override public Explanation explain (AtomicReaderContext ir, int i) throws IOException { Explanation inner = weight.explain (ir, i); - if (getBoost()!=1) { - Explanation preBoost = inner; - inner = new Explanation(inner.getValue()*getBoost(),"product of:"); - inner.addDetail(new Explanation(getBoost(),"boost")); - inner.addDetail(preBoost); - } Filter f = FilteredQuery.this.filter; DocIdSet docIdSet = f.getDocIdSet(ir); DocIdSetIterator docIdSetIterator = docIdSet == null ? DocIdSet.EMPTY_DOCIDSET.iterator() : docIdSet.iterator(); @@ -158,7 +152,7 @@ extends Query { } @Override - public float score() throws IOException { return getBoost() * scorer.score(); } + public float score() throws IOException { return scorer.score(); } }; } };