GeoJSON coordinates must be an array – How to solve this Elasticsearch exception

Opster Team

August-23, Version: 8.2-8.2

Briefly, this error occurs when the ‘coordinates’ field in a GeoJSON object is not formatted as an array. GeoJSON requires coordinates to be represented as arrays of numbers. To resolve this issue, ensure that the ‘coordinates’ field is an array of numbers. For example, a point feature would have coordinates like [100.0, 0.0]. If you’re dynamically generating GeoJSON, check your code to ensure it’s producing arrays for coordinates. If you’re manually creating GeoJSON, ensure you’re following the correct syntax.

This guide will help you check for common problems that cause the log ” GeoJSON ‘coordinates’ must be an array ” to appear. To understand the issues related to this log, read the explanation below about the following Elasticsearch concepts: .

Log Context

Log “GeoJSON ‘coordinates’ must be an array” class name is GeoUtils.java. We extracted the following from Elasticsearch source code for those seeking an in-depth context :

 coordinates = new ArrayList<>();
 while (subParser.nextToken() != Token.END_ARRAY) {
 coordinates.add(parseValidDouble(subParser; field));
 }
 } else {
 throw new ElasticsearchParseException("GeoJSON 'coordinates' must be an array");
 }
 } else if (TYPE.equals(field)) {
 if (subParser.currentToken() == Token.VALUE_STRING) {
 geojsonType = subParser.text();
 } else {

 

How helpful was this guide?

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?