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 :

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
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 {
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 {
 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 {

 

 [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.