diff options
author | Jon Bratseth <bratseth@oath.com> | 2018-10-14 15:12:49 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-10-14 15:12:49 +0200 |
commit | 5801a5e4019324cd3212ef5da40f22268c01a03c (patch) | |
tree | 4eba146e5c3c72a6245128af7fa82c81f5498a0a /container-search | |
parent | cb943c079ba1cd53f9e70e92e9c03343e85ec780 (diff) |
Revert "sort missing (null) field values"
Diffstat (limited to 'container-search')
-rw-r--r-- | container-search/src/main/java/com/yahoo/search/result/FieldComparator.java | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/container-search/src/main/java/com/yahoo/search/result/FieldComparator.java b/container-search/src/main/java/com/yahoo/search/result/FieldComparator.java index e64e0bc8f8d..21650d531be 100644 --- a/container-search/src/main/java/com/yahoo/search/result/FieldComparator.java +++ b/container-search/src/main/java/com/yahoo/search/result/FieldComparator.java @@ -57,6 +57,11 @@ public class FieldComparator extends ChainableComparator { Object a = getField(first,fieldName); Object b = getField(second,fieldName); + // If either of the values are null, don't touch the ordering + // This is to avoid problems if the sorting is called before the + // result is filled. + if ((a == null) || (b == null)) return 0; + int x = compareValues(a, b, fieldOrder.getSorter()); if (x != 0) { if (fieldOrder.getSortOrder() == Sorting.Order.DESCENDING) @@ -76,12 +81,6 @@ public class FieldComparator extends ChainableComparator { @SuppressWarnings("rawtypes") private int compareValues(Object first, Object second, Sorting.AttributeSorter s) { - if (first == null) { - if (second == null) return 0; - return -1; - } else if (second == null) { - return 1; - } if (first.getClass().isInstance(second) && first instanceof Comparable) { // We now know: |