mirror of
https://github.com/apache/lucene.git
synced 2025-02-17 07:25:59 +00:00
LUCENE-3494: Optimize FilteredQuery to remove a multiply in score()
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1179677 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
be8d9c0903
commit
20f7d1554d
@ -656,6 +656,9 @@ Optimizations
|
|||||||
* LUCENE-3426: Add NGramPhraseQuery which extends PhraseQuery and tries to
|
* LUCENE-3426: Add NGramPhraseQuery which extends PhraseQuery and tries to
|
||||||
reduce the number of terms of the query when rewrite(), in order to improve
|
reduce the number of terms of the query when rewrite(), in order to improve
|
||||||
performance. (Robert Muir, Koji Sekiguchi)
|
performance. (Robert Muir, Koji Sekiguchi)
|
||||||
|
|
||||||
|
* LUCENE-3494: Optimize FilteredQuery to remove a multiply in score()
|
||||||
|
(Uwe Schindler, Robert Muir)
|
||||||
|
|
||||||
Test Cases
|
Test Cases
|
||||||
|
|
||||||
|
@ -67,23 +67,17 @@ extends Query {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float getValueForNormalization() throws IOException {
|
public float getValueForNormalization() throws IOException {
|
||||||
return weight.getValueForNormalization() * getBoost() * getBoost();
|
return weight.getValueForNormalization() * getBoost() * getBoost(); // boost sub-weight
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void normalize (float norm, float topLevelBoost) {
|
public void normalize (float norm, float topLevelBoost) {
|
||||||
weight.normalize(norm, topLevelBoost);
|
weight.normalize(norm, topLevelBoost * getBoost()); // incorporate boost
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Explanation explain (AtomicReaderContext ir, int i) throws IOException {
|
public Explanation explain (AtomicReaderContext ir, int i) throws IOException {
|
||||||
Explanation inner = weight.explain (ir, i);
|
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;
|
Filter f = FilteredQuery.this.filter;
|
||||||
DocIdSet docIdSet = f.getDocIdSet(ir);
|
DocIdSet docIdSet = f.getDocIdSet(ir);
|
||||||
DocIdSetIterator docIdSetIterator = docIdSet == null ? DocIdSet.EMPTY_DOCIDSET.iterator() : docIdSet.iterator();
|
DocIdSetIterator docIdSetIterator = docIdSet == null ? DocIdSet.EMPTY_DOCIDSET.iterator() : docIdSet.iterator();
|
||||||
@ -158,7 +152,7 @@ extends Query {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float score() throws IOException { return getBoost() * scorer.score(); }
|
public float score() throws IOException { return scorer.score(); }
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user