lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From uschind...@apache.org
Subject svn commit: r910034 - in /lucene/java/trunk: CHANGES.txt src/java/org/apache/lucene/search/payloads/MaxPayloadFunction.java src/java/org/apache/lucene/search/payloads/MinPayloadFunction.java
Date Sun, 14 Feb 2010 16:44:46 GMT
Author: uschindler
Date: Sun Feb 14 16:44:46 2010
New Revision: 910034

URL: http://svn.apache.org/viewvc?rev=910034&view=rev
Log:
LUCENE-1941: Fix Min/MaxPayloadFunction returns 0 when only one payload is present

Modified:
    lucene/java/trunk/CHANGES.txt
    lucene/java/trunk/src/java/org/apache/lucene/search/payloads/MaxPayloadFunction.java
    lucene/java/trunk/src/java/org/apache/lucene/search/payloads/MinPayloadFunction.java

Modified: lucene/java/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/java/trunk/CHANGES.txt?rev=910034&r1=910033&r2=910034&view=diff
==============================================================================
--- lucene/java/trunk/CHANGES.txt (original)
+++ lucene/java/trunk/CHANGES.txt Sun Feb 14 16:44:46 2010
@@ -235,6 +235,10 @@
    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
 

Modified: lucene/java/trunk/src/java/org/apache/lucene/search/payloads/MaxPayloadFunction.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/search/payloads/MaxPayloadFunction.java?rev=910034&r1=910033&r2=910034&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/search/payloads/MaxPayloadFunction.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/search/payloads/MaxPayloadFunction.java Sun
Feb 14 16:44:46 2010
@@ -27,7 +27,11 @@
 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

Modified: lucene/java/trunk/src/java/org/apache/lucene/search/payloads/MinPayloadFunction.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/search/payloads/MinPayloadFunction.java?rev=910034&r1=910033&r2=910034&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/search/payloads/MinPayloadFunction.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/search/payloads/MinPayloadFunction.java Sun
Feb 14 16:44:46 2010
@@ -23,9 +23,13 @@
  **/
 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



Mime
View raw message