Illegal longitude value for – How to solve this Elasticsearch exception

Opster Team

August-23, Version: 6.8-7.15

Briefly, this error occurs when an invalid longitude value is provided for a geo-point field in Elasticsearch. Longitude values should be between -180 and +180 degrees. If the value is outside this range, Elasticsearch will throw this error. To resolve this issue, ensure that all longitude values are within the acceptable 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 longitude 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 longitude value [{}] for [{}]” class name is GeoPolygonQueryBuilder.java. We extracted the following from Elasticsearch source code for those seeking an in-depth context :

 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]