Illegal latitude value for – How to solve this Elasticsearch exception

Opster Team

August-23, Version: 6.8-7.15

Briefly, this error occurs when an invalid latitude value is provided for a geo-point field in Elasticsearch. Latitude values should be between -90 and 90 degrees. If the value is outside this range, Elasticsearch will throw this error. To resolve this issue, ensure that all latitude values are within the valid range. If you’re using a script or application to generate these values, check the logic to prevent invalid values. Also, validate your data before indexing to avoid such errors.

This guide will help you check for common problems that cause the log ” illegal latitude value [{}] for [{}] ” to appear. To understand the issues related to this log, read the explanation below about the following Elasticsearch concepts: index, query.

Log Context

Log “illegal latitude value [{}] for [{}]” class name is GeoPolygonQueryBuilder.java. We extracted the following from Elasticsearch source code for those seeking an in-depth context :

 // validation was not available prior to 2.x; so to support bwc
 // percolation queries we only ignore_malformed on 2.x created indexes
 if (GeoValidationMethod.isIgnoreMalformed(validationMethod) == false) {
 for (GeoPoint point : shell) {
 if (GeoUtils.isValidLatitude(point.lat()) == false) {
 throw new QueryShardException(context; "illegal latitude value [{}] for [{}]"; point.lat();
 GeoPolygonQueryBuilder.NAME);
 }
 if (GeoUtils.isValidLongitude(point.lon()) == false) {
 throw new QueryShardException(context; "illegal longitude value [{}] for [{}]"; point.lon();
 GeoPolygonQueryBuilder.NAME);

 

 [ratemypost]