mirror of https://github.com/apache/lucene.git
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:
parent
08ecae8c87
commit
23aacd101f
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue