From 1d2f95857d5e29fef6d951ede438ee4af4fa74cb Mon Sep 17 00:00:00 2001 From: kimchy Date: Tue, 3 May 2011 16:16:30 +0300 Subject: [PATCH] Sort missing wrongly sorts negative values, closes #772. --- .../index/field/data/doubles/DoubleFieldDataType.java | 4 ++-- .../index/field/data/floats/FloatFieldDataType.java | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/field/data/doubles/DoubleFieldDataType.java b/modules/elasticsearch/src/main/java/org/elasticsearch/index/field/data/doubles/DoubleFieldDataType.java index c96eef52e01..7a23f5de51e 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/index/field/data/doubles/DoubleFieldDataType.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/index/field/data/doubles/DoubleFieldDataType.java @@ -43,14 +43,14 @@ public class DoubleFieldDataType implements FieldDataType { if (missing.equals("_last")) { return new FieldComparatorSource() { @Override public FieldComparator newComparator(String fieldname, int numHits, int sortPos, boolean reversed) throws IOException { - return new DoubleFieldDataMissingComparator(numHits, fieldname, cache, reversed ? Double.MIN_VALUE : Double.MAX_VALUE); + return new DoubleFieldDataMissingComparator(numHits, fieldname, cache, reversed ? Double.NEGATIVE_INFINITY : Double.POSITIVE_INFINITY); } }; } if (missing.equals("_first")) { return new FieldComparatorSource() { @Override public FieldComparator newComparator(String fieldname, int numHits, int sortPos, boolean reversed) throws IOException { - return new DoubleFieldDataMissingComparator(numHits, fieldname, cache, reversed ? Double.MAX_VALUE : Double.MIN_VALUE); + return new DoubleFieldDataMissingComparator(numHits, fieldname, cache, reversed ? Double.POSITIVE_INFINITY : Double.NEGATIVE_INFINITY); } }; } diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/field/data/floats/FloatFieldDataType.java b/modules/elasticsearch/src/main/java/org/elasticsearch/index/field/data/floats/FloatFieldDataType.java index f58362bf263..a2e7408554f 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/index/field/data/floats/FloatFieldDataType.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/index/field/data/floats/FloatFieldDataType.java @@ -43,14 +43,14 @@ public class FloatFieldDataType implements FieldDataType { if (missing.equals("_last")) { return new FieldComparatorSource() { @Override public FieldComparator newComparator(String fieldname, int numHits, int sortPos, boolean reversed) throws IOException { - return new FloatFieldDataMissingComparator(numHits, fieldname, cache, reversed ? Float.MIN_VALUE : Float.MAX_VALUE); + return new FloatFieldDataMissingComparator(numHits, fieldname, cache, reversed ? Float.NEGATIVE_INFINITY : Float.POSITIVE_INFINITY); } }; } if (missing.equals("_first")) { return new FieldComparatorSource() { @Override public FieldComparator newComparator(String fieldname, int numHits, int sortPos, boolean reversed) throws IOException { - return new FloatFieldDataMissingComparator(numHits, fieldname, cache, reversed ? Float.MAX_VALUE : Float.MIN_VALUE); + return new FloatFieldDataMissingComparator(numHits, fieldname, cache, reversed ? Float.POSITIVE_INFINITY : Float.NEGATIVE_INFINITY); } }; }