LUCENE-1941: Fix Min/MaxPayloadFunction returns 0 when only one payload is present

git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@910034 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Uwe Schindler 2010-02-14 16:44:46 +00:00
parent 08ecae8c87
commit 23aacd101f
3 changed files with 16 additions and 4 deletions

View File

@ -235,6 +235,10 @@ Bug fixes
reference to the Attribute/AttributeImpl classes which prevents
unloading of custom attributes loaded by other classloaders
(e.g. in Solr plugins). (Uwe Schindler)
* LUCENE-1941: Fix Min/MaxPayloadFunction returns 0 when
only one payload is present. (Erik Hatcher, Mike McCandless
via Uwe Schindler)
API Changes

View File

@ -27,7 +27,11 @@ package org.apache.lucene.search.payloads;
public class MaxPayloadFunction extends PayloadFunction {
@Override
public float currentScore(int docId, String field, int start, int end, int numPayloadsSeen, float currentScore, float currentPayloadScore) {
return Math.max(currentPayloadScore, currentScore);
if (numPayloadsSeen == 0) {
return currentPayloadScore;
} else {
return Math.max(currentPayloadScore, currentScore);
}
}
@Override

View File

@ -23,9 +23,13 @@ package org.apache.lucene.search.payloads;
**/
public class MinPayloadFunction extends PayloadFunction {
@Override
public float currentScore(int docId, String field, int start, int end, int numPayloadsSeen, float currentScore, float currentPayloadScore) {
return Math.min(currentPayloadScore, currentScore);
@Override
public float currentScore(int docId, String field, int start, int end, int numPayloadsSeen, float currentScore, float currentPayloadScore) {
if (numPayloadsSeen == 0) {
return currentPayloadScore;
} else {
return Math.min(currentPayloadScore, currentScore);
}
}
@Override