diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/search/facets/geodistance/GeoDistanceFacetCollectorParser.java b/modules/elasticsearch/src/main/java/org/elasticsearch/search/facets/geodistance/GeoDistanceFacetCollectorParser.java index 7debd890f60..7116a8c6d5e 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/search/facets/geodistance/GeoDistanceFacetCollectorParser.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/search/facets/geodistance/GeoDistanceFacetCollectorParser.java @@ -155,6 +155,10 @@ public class GeoDistanceFacetCollectorParser implements FacetCollectorParser { throw new FacetPhaseExecutionException(facetName, "lat/lon not set for geo_distance facet"); } + if (entries.isEmpty()) { + throw new FacetPhaseExecutionException(facetName, "no ranges defined for geo_distance facet"); + } + if (valueFieldName != null) { return new ValueGeoDistanceFacetCollector(facetName, fieldName, lat, lon, unit, geoDistance, entries.toArray(new GeoDistanceFacet.Entry[entries.size()]), context.fieldDataCache(), context.mapperService(), valueFieldName);