瀏覽代碼

#2831 Ensure score is finite before adding to API response in SearchHelper and DefaultSearcher.

Shinsuke Sugaya 11 月之前
父節點
當前提交
93354ce179

+ 4 - 1
src/main/java/org/codelibs/fess/helper/SearchHelper.java

@@ -217,7 +217,10 @@ public class SearchHelper {
                     }
 
                     if (!docMap.containsKey(Constants.SCORE)) {
-                        docMap.put(Constants.SCORE, hit.getScore());
+                        final float score = hit.getScore();
+                        if (Float.isFinite(score)) {
+                            docMap.put(Constants.SCORE, score);
+                        }
                     }
 
                     docMap.put(fessConfig.getIndexFieldId(), hit.getId());

+ 4 - 1
src/main/java/org/codelibs/fess/rank/fusion/DefaultSearcher.java

@@ -184,7 +184,10 @@ public class DefaultSearcher extends RankFusionSearcher {
         }
 
         if (!docMap.containsKey(Constants.SCORE)) {
-            docMap.put(Constants.SCORE, searchHit.getScore());
+            final float score = searchHit.getScore();
+            if (Float.isFinite(score)) {
+                docMap.put(Constants.SCORE, score);
+            }
         }
 
         if (!docMap.containsKey(fessConfig.getIndexFieldId())) {