-
Notifications
You must be signed in to change notification settings - Fork 1.3k
TopGroupsCollector#getTopGroups() returns NaN maxScore when no hits for a group value #15872
Copy link
Copy link
Open
Labels
Description
Description
In TopGroupsCollector#getTopGroups() method, if there're no hits for a group value, then groupMaxScore is NaN:
lucene/lucene/grouping/src/java/org/apache/lucene/search/grouping/TopGroupsCollector.java
Line 178 in 1f0bc36
| allTopDocs.scoreDocs.length == 0 ? Float.NaN : allTopDocs.scoreDocs[0].score; |
, this causes the following code Math.max(maxScore, groupMaxScore) always returns NaN in the next for loop, so the final maxScore is NaN.
lucene/lucene/grouping/src/java/org/apache/lucene/search/grouping/TopGroupsCollector.java
Line 207 in 1f0bc36
| maxScore = Math.max(maxScore, groupMaxScore); |
See the debug info:
We should use the same way like TopGroups#nonNANmax() to avoid that issue:
| private static float nonNANmax(float a, float b) { |
Need to check if other places have the same issue.
Version and environment details
All versions.
Reactions are currently unavailable