diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/search/facet/datehistogram/InternalFullDateHistogramFacet.java b/modules/elasticsearch/src/main/java/org/elasticsearch/search/facet/datehistogram/InternalFullDateHistogramFacet.java index 5190e684d7b..388eae1f2a5 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/search/facet/datehistogram/InternalFullDateHistogramFacet.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/search/facet/datehistogram/InternalFullDateHistogramFacet.java @@ -61,8 +61,8 @@ public class InternalFullDateHistogramFacet extends InternalDateHistogramFacet { long count; long totalCount; double total; - double min = Double.MAX_VALUE; - double max = Double.MIN_VALUE; + double min = Double.POSITIVE_INFINITY; + double max = Double.NEGATIVE_INFINITY; public FullEntry(long time, long count, double min, double max, long totalCount, double total) { this.time = time; diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/search/facet/datehistogram/ValueDateHistogramFacetCollector.java b/modules/elasticsearch/src/main/java/org/elasticsearch/search/facet/datehistogram/ValueDateHistogramFacetCollector.java index ba2331e2c22..44763cbad06 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/search/facet/datehistogram/ValueDateHistogramFacetCollector.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/search/facet/datehistogram/ValueDateHistogramFacetCollector.java @@ -125,7 +125,7 @@ public class ValueDateHistogramFacetCollector extends AbstractFacetCollector { InternalFullDateHistogramFacet.FullEntry entry = entries.get(time); if (entry == null) { - entry = new InternalFullDateHistogramFacet.FullEntry(time, 0, Double.MAX_VALUE, Double.MIN_VALUE, 0, 0); + entry = new InternalFullDateHistogramFacet.FullEntry(time, 0, Double.POSITIVE_INFINITY, Double.NEGATIVE_INFINITY, 0, 0); entries.put(time, entry); } entry.count++; diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/search/facet/geodistance/GeoDistanceFacet.java b/modules/elasticsearch/src/main/java/org/elasticsearch/search/facet/geodistance/GeoDistanceFacet.java index df088326eef..dc025cade62 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/search/facet/geodistance/GeoDistanceFacet.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/search/facet/geodistance/GeoDistanceFacet.java @@ -53,8 +53,8 @@ public interface GeoDistanceFacet extends Facet, Iterable { long totalCount; double total; - double min = Double.MAX_VALUE; - double max = Double.MIN_VALUE; + double min = Double.POSITIVE_INFINITY; + double max = Double.NEGATIVE_INFINITY; /** * Internal field used in facet collection diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/search/facet/statistical/ScriptStatisticalFacetCollector.java b/modules/elasticsearch/src/main/java/org/elasticsearch/search/facet/statistical/ScriptStatisticalFacetCollector.java index 44875a9e5ad..6b6bd460da0 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/search/facet/statistical/ScriptStatisticalFacetCollector.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/search/facet/statistical/ScriptStatisticalFacetCollector.java @@ -36,9 +36,9 @@ public class ScriptStatisticalFacetCollector extends AbstractFacetCollector { private final SearchScript script; - private double min = Double.MAX_VALUE; + private double min = Double.POSITIVE_INFINITY; - private double max = Double.MIN_VALUE; + private double max = Double.NEGATIVE_INFINITY; private double total = 0; @@ -74,12 +74,6 @@ public class ScriptStatisticalFacetCollector extends AbstractFacetCollector { } @Override public Facet facet() { - if (min == Double.MAX_VALUE) { - min = Double.NaN; - } - if (max == Double.MIN_VALUE) { - max = Double.NaN; - } return new InternalStatisticalFacet(facetName, min, max, total, sumOfSquares, count); } } \ No newline at end of file diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/search/facet/statistical/StatisticalFacetCollector.java b/modules/elasticsearch/src/main/java/org/elasticsearch/search/facet/statistical/StatisticalFacetCollector.java index fcfd4590c79..c3f5ec2a6e5 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/search/facet/statistical/StatisticalFacetCollector.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/search/facet/statistical/StatisticalFacetCollector.java @@ -73,20 +73,14 @@ public class StatisticalFacetCollector extends AbstractFacetCollector { } @Override public Facet facet() { - if (statsProc.min == Double.MAX_VALUE) { - statsProc.min = Double.NaN; - } - if (statsProc.max == Double.MIN_VALUE) { - statsProc.max = Double.NaN; - } return new InternalStatisticalFacet(facetName, statsProc.min(), statsProc.max(), statsProc.total(), statsProc.sumOfSquares(), statsProc.count()); } public static class StatsProc implements NumericFieldData.MissingDoubleValueInDocProc { - double min = Double.MAX_VALUE; + double min = Double.POSITIVE_INFINITY; - double max = Double.MIN_VALUE; + double max = Double.NEGATIVE_INFINITY; double total = 0; diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/search/facet/statistical/StatisticalFieldsFacetCollector.java b/modules/elasticsearch/src/main/java/org/elasticsearch/search/facet/statistical/StatisticalFieldsFacetCollector.java index 8c93870f7f5..b8204d24015 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/search/facet/statistical/StatisticalFieldsFacetCollector.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/search/facet/statistical/StatisticalFieldsFacetCollector.java @@ -78,20 +78,14 @@ public class StatisticalFieldsFacetCollector extends AbstractFacetCollector { } @Override public Facet facet() { - if (statsProc.min == Double.MAX_VALUE) { - statsProc.min = Double.NaN; - } - if (statsProc.max == Double.MIN_VALUE) { - statsProc.max = Double.NaN; - } return new InternalStatisticalFacet(facetName, statsProc.min(), statsProc.max(), statsProc.total(), statsProc.sumOfSquares(), statsProc.count()); } public static class StatsProc implements NumericFieldData.MissingDoubleValueInDocProc { - double min = Double.MAX_VALUE; + double min = Double.POSITIVE_INFINITY; - double max = Double.MIN_VALUE; + double max = Double.NEGATIVE_INFINITY; double total = 0; diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/search/facet/termsstats/doubles/TermsStatsDoubleFacetCollector.java b/modules/elasticsearch/src/main/java/org/elasticsearch/search/facet/termsstats/doubles/TermsStatsDoubleFacetCollector.java index 39cc9f09f57..eba1724b502 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/search/facet/termsstats/doubles/TermsStatsDoubleFacetCollector.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/search/facet/termsstats/doubles/TermsStatsDoubleFacetCollector.java @@ -162,7 +162,7 @@ public class TermsStatsDoubleFacetCollector extends AbstractFacetCollector { @Override public void onValue(int docId, double value) { InternalTermsStatsDoubleFacet.DoubleEntry doubleEntry = entries.get(value); if (doubleEntry == null) { - doubleEntry = new InternalTermsStatsDoubleFacet.DoubleEntry(value, 0, 0, 0, Double.MAX_VALUE, Double.MIN_VALUE); + doubleEntry = new InternalTermsStatsDoubleFacet.DoubleEntry(value, 0, 0, 0, Double.POSITIVE_INFINITY, Double.NEGATIVE_INFINITY); entries.put(value, doubleEntry); } doubleEntry.count++; @@ -202,7 +202,7 @@ public class TermsStatsDoubleFacetCollector extends AbstractFacetCollector { @Override public void onValue(int docId, double value) { InternalTermsStatsDoubleFacet.DoubleEntry doubleEntry = entries.get(value); if (doubleEntry == null) { - doubleEntry = new InternalTermsStatsDoubleFacet.DoubleEntry(value, 1, 0, 0, Double.MAX_VALUE, Double.MIN_VALUE); + doubleEntry = new InternalTermsStatsDoubleFacet.DoubleEntry(value, 1, 0, 0, Double.POSITIVE_INFINITY, Double.NEGATIVE_INFINITY); entries.put(value, doubleEntry); } else { doubleEntry.count++; diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/search/facet/termsstats/longs/TermsStatsLongFacetCollector.java b/modules/elasticsearch/src/main/java/org/elasticsearch/search/facet/termsstats/longs/TermsStatsLongFacetCollector.java index 7c58f93ce2b..9218daef920 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/search/facet/termsstats/longs/TermsStatsLongFacetCollector.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/search/facet/termsstats/longs/TermsStatsLongFacetCollector.java @@ -165,7 +165,7 @@ public class TermsStatsLongFacetCollector extends AbstractFacetCollector { @Override public void onValue(int docId, long value) { InternalTermsStatsLongFacet.LongEntry longEntry = entries.get(value); if (longEntry == null) { - longEntry = new InternalTermsStatsLongFacet.LongEntry(value, 0, 0, 0, Double.MAX_VALUE, Double.MIN_VALUE); + longEntry = new InternalTermsStatsLongFacet.LongEntry(value, 0, 0, 0, Double.POSITIVE_INFINITY, Double.NEGATIVE_INFINITY); entries.put(value, longEntry); } longEntry.count++; @@ -205,7 +205,7 @@ public class TermsStatsLongFacetCollector extends AbstractFacetCollector { @Override public void onValue(int docId, long value) { InternalTermsStatsLongFacet.LongEntry longEntry = entries.get(value); if (longEntry == null) { - longEntry = new InternalTermsStatsLongFacet.LongEntry(value, 1, 0, 0, Double.MAX_VALUE, Double.MIN_VALUE); + longEntry = new InternalTermsStatsLongFacet.LongEntry(value, 1, 0, 0, Double.POSITIVE_INFINITY, Double.NEGATIVE_INFINITY); entries.put(value, longEntry); } else { longEntry.count++; diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/search/facet/termsstats/strings/TermsStatsStringFacetCollector.java b/modules/elasticsearch/src/main/java/org/elasticsearch/search/facet/termsstats/strings/TermsStatsStringFacetCollector.java index 78e8cde29ac..5ee9c6831c7 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/search/facet/termsstats/strings/TermsStatsStringFacetCollector.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/search/facet/termsstats/strings/TermsStatsStringFacetCollector.java @@ -164,7 +164,7 @@ public class TermsStatsStringFacetCollector extends AbstractFacetCollector { @Override public void onValue(int docId, String value) { InternalTermsStatsStringFacet.StringEntry stringEntry = entries.get(value); if (stringEntry == null) { - stringEntry = new InternalTermsStatsStringFacet.StringEntry(value, 0, 0, 0, Double.MAX_VALUE, Double.MIN_VALUE); + stringEntry = new InternalTermsStatsStringFacet.StringEntry(value, 0, 0, 0, Double.POSITIVE_INFINITY, Double.NEGATIVE_INFINITY); entries.put(value, stringEntry); } stringEntry.count++; @@ -203,7 +203,7 @@ public class TermsStatsStringFacetCollector extends AbstractFacetCollector { @Override public void onValue(int docId, String value) { InternalTermsStatsStringFacet.StringEntry stringEntry = entries.get(value); if (stringEntry == null) { - stringEntry = new InternalTermsStatsStringFacet.StringEntry(value, 1, 0, 0, Double.MAX_VALUE, Double.MIN_VALUE); + stringEntry = new InternalTermsStatsStringFacet.StringEntry(value, 1, 0, 0, Double.POSITIVE_INFINITY, Double.NEGATIVE_INFINITY); entries.put(value, stringEntry); } else { stringEntry.count++;