-
Notifications
You must be signed in to change notification settings - Fork 24.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changing the sorting for terms aggs, #5237
Conversation
return asc ? 1 : -1; | ||
if (Double.isNaN(v1)) { | ||
return 1; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe this should even be
if (Double.isNaN(v1)) {
if (Double.isNaN(v2)) {
return 0;
} else {
return 1;
}
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (Double.isNaN(v1)) {
return Double.isNaN(v2) ? 0 : 1;
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the suggestion of @uboness is more readable than the extra if-statement and indents. I'll change it to that one for a complete implementation of the comparator contract.
Thnx
The fix look good. Can you write a unit test for this? (If that looks complicated to you, I can take care of this, just let me know!) |
I've been looking into the test, but I find it hard to see where to add what :). I found Would you mind adding a test? |
Indeed, this would be easier to have a different test case.
Sure, I will work on it! |
left one comment... other than that LGTM |
This pull request fixes the sorting of aggregations as discussed in issue #5236.
It forces the
NaN
values to be pushed to the bottom of the list, no matter if you are sorting asc/desc. This way top lists show the most relevant aggregates in the top. Also it actually does what the comments above it already said it should do.Closes #5236.