Geo distance requires distance to be specified – How to solve this Elasticsearch exception

Opster Team

August-23, Version: 6.8-8.9

Briefly, this error occurs when a ā€˜distance’ parameter is not specified in a ā€˜geo_distance’ query in Elasticsearch. The ā€˜geo_distance’ query is used to find documents that are within a certain distance from a geographical point. To resolve this issue, you need to specify the ā€˜distance’ parameter in your query. This can be done by adding a ā€˜distance’ field to your query and providing a value for it. The value should be a number followed by a distance unit, such as ā€œ12kmā€ or ā€œ5miā€.

This guide will help you check for common problems that cause the log ā€ geo_distance requires ā€˜distance’ to be specified ā€ to appear. To understand the issues related to this log, read the explanation below about the following Elasticsearch concepts: query, index.

Log Context

Log ā€œgeo_distance requires ā€˜distance’ to be specifiedā€ class name is GeoDistanceQueryBuilder.java. We extracted the following from Elasticsearch source code for those seeking an in-depth context :

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
}
}
} if (vDistance == null) {
throw new ParsingException(parser.getTokenLocation(); "geo_distance requires 'distance' to be specified");
} GeoDistanceQueryBuilder qb = new GeoDistanceQueryBuilder(fieldName);
if (vDistance instanceof Number) {
qb.distance(((Number) vDistance).doubleValue(); unit);<p></p>
} } } if (vDistance == null) { throw new ParsingException(parser.getTokenLocation(); "geo_distance requires 'distance' to be specified"); } GeoDistanceQueryBuilder qb = new GeoDistanceQueryBuilder(fieldName); if (vDistance instanceof Number) { qb.distance(((Number) vDistance).doubleValue(); unit);<p></p>
 }
 }
 }  if (vDistance == null) {
 throw new ParsingException(parser.getTokenLocation(); "geo_distance requires 'distance' to be specified");
 }  GeoDistanceQueryBuilder qb = new GeoDistanceQueryBuilder(fieldName);
 if (vDistance instanceof Number) {
 qb.distance(((Number) vDistance).doubleValue(); unit);

 

 [ratemypost]

Opster
Privacy Overview

This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.