mirror of https://github.com/apache/lucene.git
fix FieldSortedHitQueue.maxscore: LUCENE-462
git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@332651 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
d37e5cc906
commit
34c98cc0bf
|
@ -250,6 +250,10 @@ Bug fixes
|
|||
missing or duplicate docs due to equal docs sorting in an arbitrary order.
|
||||
(Yonik Seeley, LUCENE-456)
|
||||
|
||||
17. A single hit using the expert level sorted search methods
|
||||
resulted in the score not being normalized.
|
||||
(Yonik Seeley, LUCENE-462)
|
||||
|
||||
Optimizations
|
||||
|
||||
1. Disk usage (peak requirements during indexing and optimization)
|
||||
|
|
|
@ -68,11 +68,29 @@ extends PriorityQueue {
|
|||
/** Stores the sort criteria being used. */
|
||||
protected SortField[] fields;
|
||||
|
||||
/** Stores the maximum score value encountered, for normalizing.
|
||||
* we only care about scores greater than 1.0 - if all the scores
|
||||
* are less than 1.0, we don't have to normalize. */
|
||||
protected float maxscore = 1.0f;
|
||||
/** Stores the maximum score value encountered, needed for normalizing. */
|
||||
protected float maxscore = Float.NEGATIVE_INFINITY;
|
||||
|
||||
/** returns the maximum score encountered by elements inserted via insert()
|
||||
*/
|
||||
public float getMaxScore() {
|
||||
return maxscore;
|
||||
}
|
||||
|
||||
// The signature of this method takes a FieldDoc in order to avoid
|
||||
// the unneeded cast to retrieve the score.
|
||||
// inherit javadoc
|
||||
public boolean insert(FieldDoc fdoc) {
|
||||
maxscore = Math.max(maxscore,fdoc.score);
|
||||
return super.insert(fdoc);
|
||||
}
|
||||
|
||||
// This overrides PriorityQueue.insert() so that insert(FieldDoc) that
|
||||
// keeps track of the score isn't accidentally bypassed.
|
||||
// inherit javadoc
|
||||
public boolean insert(Object fdoc) {
|
||||
return insert((FieldDoc)fdoc);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether <code>a</code> is less relevant than <code>b</code>.
|
||||
|
@ -84,10 +102,6 @@ extends PriorityQueue {
|
|||
final ScoreDoc docA = (ScoreDoc) a;
|
||||
final ScoreDoc docB = (ScoreDoc) b;
|
||||
|
||||
// keep track of maximum score
|
||||
if (docA.score > maxscore) maxscore = docA.score;
|
||||
if (docB.score > maxscore) maxscore = docB.score;
|
||||
|
||||
// run comparators
|
||||
final int n = comparators.length;
|
||||
int c = 0;
|
||||
|
|
|
@ -516,7 +516,7 @@ implements Serializable {
|
|||
|
||||
TopDocs docs2 = full.search(queryE, filt, nDocs, sort);
|
||||
|
||||
// assertEquals(docs1.scoreDocs[0].score, docs2.scoreDocs[0].score, 1e-6);
|
||||
assertEquals(docs1.scoreDocs[0].score, docs2.scoreDocs[0].score, 1e-6);
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue