diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/search/facets/internal/InternalFacets.java b/modules/elasticsearch/src/main/java/org/elasticsearch/search/facets/internal/InternalFacets.java index 5f4fc0d2510..649b8212a65 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/search/facets/internal/InternalFacets.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/search/facets/internal/InternalFacets.java @@ -33,7 +33,7 @@ import org.elasticsearch.search.facets.filter.InternalFilterFacet; import org.elasticsearch.search.facets.geodistance.InternalGeoDistanceFacet; import org.elasticsearch.search.facets.histogram.InternalHistogramFacet; import org.elasticsearch.search.facets.query.InternalQueryFacet; -import org.elasticsearch.search.facets.range.InternalRangeDistanceFacet; +import org.elasticsearch.search.facets.range.InternalRangeFacet; import org.elasticsearch.search.facets.statistical.InternalStatisticalFacet; import org.elasticsearch.search.facets.terms.InternalTermsFacet; @@ -148,7 +148,7 @@ public class InternalFacets implements Facets, Streamable, ToXContent, Iterable< } else if (id == Facet.Type.GEO_DISTANCE.id()) { facets.add(InternalGeoDistanceFacet.readGeoDistanceFacet(in)); } else if (id == Facet.Type.RANGE.id()) { - facets.add(InternalRangeDistanceFacet.readRangeFacet(in)); + facets.add(InternalRangeFacet.readRangeFacet(in)); } else if (id == Facet.Type.FILTER.id()) { facets.add(InternalFilterFacet.readFilterFacet(in)); } else { diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/search/facets/range/InternalRangeDistanceFacet.java b/modules/elasticsearch/src/main/java/org/elasticsearch/search/facets/range/InternalRangeFacet.java similarity index 90% rename from modules/elasticsearch/src/main/java/org/elasticsearch/search/facets/range/InternalRangeDistanceFacet.java rename to modules/elasticsearch/src/main/java/org/elasticsearch/search/facets/range/InternalRangeFacet.java index 345f6a9aaeb..e6f5e5760fa 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/search/facets/range/InternalRangeDistanceFacet.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/search/facets/range/InternalRangeFacet.java @@ -33,7 +33,7 @@ import java.util.List; /** * @author kimchy (shay.banon) */ -public class InternalRangeDistanceFacet implements RangeFacet, InternalFacet { +public class InternalRangeFacet implements RangeFacet, InternalFacet { private String name; @@ -43,10 +43,10 @@ public class InternalRangeDistanceFacet implements RangeFacet, InternalFacet { private Entry[] entries; - InternalRangeDistanceFacet() { + InternalRangeFacet() { } - public InternalRangeDistanceFacet(String name, String keyFieldName, String valueFieldName, Entry[] entries) { + public InternalRangeFacet(String name, String keyFieldName, String valueFieldName, Entry[] entries) { this.name = name; this.keyFieldName = keyFieldName; this.valueFieldName = valueFieldName; @@ -98,12 +98,12 @@ public class InternalRangeDistanceFacet implements RangeFacet, InternalFacet { } @Override public Facet aggregate(Iterable facets) { - InternalRangeDistanceFacet agg = null; + InternalRangeFacet agg = null; for (Facet facet : facets) { if (!facet.name().equals(name)) { continue; } - InternalRangeDistanceFacet geoDistanceFacet = (InternalRangeDistanceFacet) facet; + InternalRangeFacet geoDistanceFacet = (InternalRangeFacet) facet; if (agg == null) { agg = geoDistanceFacet; } else { @@ -116,8 +116,8 @@ public class InternalRangeDistanceFacet implements RangeFacet, InternalFacet { return agg; } - public static InternalRangeDistanceFacet readRangeFacet(StreamInput in) throws IOException { - InternalRangeDistanceFacet facet = new InternalRangeDistanceFacet(); + public static InternalRangeFacet readRangeFacet(StreamInput in) throws IOException { + InternalRangeFacet facet = new InternalRangeFacet(); facet.readFrom(in); return facet; } @@ -186,7 +186,7 @@ public class InternalRangeDistanceFacet implements RangeFacet, InternalFacet { builder.field("to", entry.to); } if (entry.toAsString != null) { - builder.field("to_str", entry.fromAsString); + builder.field("to_str", entry.toAsString); } builder.field("count", entry.count()); builder.field("total", entry.total()); diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/search/facets/range/KeyValueRangeFacetCollector.java b/modules/elasticsearch/src/main/java/org/elasticsearch/search/facets/range/KeyValueRangeFacetCollector.java index ad609ad4394..e6ec3a4e329 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/search/facets/range/KeyValueRangeFacetCollector.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/search/facets/range/KeyValueRangeFacetCollector.java @@ -139,6 +139,6 @@ public class KeyValueRangeFacetCollector extends AbstractFacetCollector { } @Override public Facet facet() { - return new InternalRangeDistanceFacet(facetName, keyFieldName, valueFieldName, entries); + return new InternalRangeFacet(facetName, keyFieldName, valueFieldName, entries); } } diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/search/facets/range/RangeFacetCollector.java b/modules/elasticsearch/src/main/java/org/elasticsearch/search/facets/range/RangeFacetCollector.java index 104acf83b6b..759d8d81a0a 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/search/facets/range/RangeFacetCollector.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/search/facets/range/RangeFacetCollector.java @@ -81,7 +81,7 @@ public class RangeFacetCollector extends AbstractFacetCollector { } @Override public Facet facet() { - return new InternalRangeDistanceFacet(facetName, fieldName, fieldName, entries); + return new InternalRangeFacet(facetName, fieldName, fieldName, entries); } public static class RangeProc implements NumericFieldData.DoubleValueInDocProc { diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/search/facets/range/ScriptRangeFacetCollector.java b/modules/elasticsearch/src/main/java/org/elasticsearch/search/facets/range/ScriptRangeFacetCollector.java index ebc3b78937d..6c83c9210a1 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/search/facets/range/ScriptRangeFacetCollector.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/search/facets/range/ScriptRangeFacetCollector.java @@ -68,6 +68,6 @@ public class ScriptRangeFacetCollector extends AbstractFacetCollector { } @Override public Facet facet() { - return new InternalRangeDistanceFacet(facetName, "_na", "_na", entries); + return new InternalRangeFacet(facetName, "_na", "_na", entries); } } diff --git a/modules/test/integration/src/test/java/org/elasticsearch/test/integration/search/facets/SimpleFacetsTests.java b/modules/test/integration/src/test/java/org/elasticsearch/test/integration/search/facets/SimpleFacetsTests.java index 86aa98fab95..be7a3b4f5ca 100644 --- a/modules/test/integration/src/test/java/org/elasticsearch/test/integration/search/facets/SimpleFacetsTests.java +++ b/modules/test/integration/src/test/java/org/elasticsearch/test/integration/search/facets/SimpleFacetsTests.java @@ -598,10 +598,13 @@ public class SimpleFacetsTests extends AbstractNodesTests { assertThat(facet.name(), equalTo("range1")); assertThat(facet.entries().size(), equalTo(3)); assertThat(facet.entries().get(0).to(), closeTo(1056, 0.000001)); + assertThat(Double.parseDouble(facet.entries().get(0).toAsString()), closeTo(1056, 0.000001)); assertThat(facet.entries().get(0).count(), equalTo(1l)); assertThat(facet.entries().get(0).total(), closeTo(1055, 0.000001)); assertThat(facet.entries().get(1).from(), closeTo(1000, 0.000001)); + assertThat(Double.parseDouble(facet.entries().get(1).fromAsString()), closeTo(1000, 0.000001)); assertThat(facet.entries().get(1).to(), closeTo(1170, 0.000001)); + assertThat(Double.parseDouble(facet.entries().get(1).toAsString()), closeTo(1170, 0.000001)); assertThat(facet.entries().get(1).count(), equalTo(2l)); assertThat(facet.entries().get(1).total(), closeTo(1055 + 1065, 0.000001)); assertThat(facet.entries().get(2).from(), closeTo(1170, 0.000001));