# Geojson to Elasticsearch : Failed to parse field \[geometry.coordinates\] of type \[geo\_shape\]

**URL:** <https://discuss.elastic.co/t/geojson-to-elasticsearch-failed-to-parse-field-geometry-coordinates-of-type-geo-shape/235261>\
**Category:** Elasticsearch\
**Created:** [June 2, 2020, 1:09am UTC](https://discuss.elastic.co/t/geojson-to-elasticsearch-failed-to-parse-field-geometry-coordinates-of-type-geo-shape/235261 "2020-06-02T01:09:18Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Scorpion21](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/scorpion21/32/48483_2.png) [@Scorpion21](https://discuss.elastic.co/u/Scorpion21)\
**Post date:** [June 2, 2020, 1:09am UTC](https://discuss.elastic.co/t/geojson-to-elasticsearch-failed-to-parse-field-geometry-coordinates-of-type-geo-shape/235261/1 "2020-06-02T01:09:18Z")

</div>

I am trying to indexing geojson file into elasticsearch (version 7.6.2) using Python.

Here is the mapping I defined in elasticsearch.

```
'mappings': {
  "properties": {
    "geometry": {
      "properties": {
        "coordinates": {
          "type": "geo_shape"
        },
        "type": {
          "type": "text",
          "fields": {
            "keyword": {
              "type": "keyword",
              "ignore_above": 256
            }
          }
        }
      }
    },    
 }
}

```

This is my geojson file

```
    {
    "type": "FeatureCollection",
    "name": "testting",
    "crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:OGC:1.3:CRS84" } },
    "features": [
    { "type": "Feature", "properties": { "LEGEND": "x_1", "THRESHOLD": -109, "COLOR": "0 0 255", "Prediction": "Coverage" }, "geometry": { "type": "MultiPolygon", "coordinates": [[ [ [ 151.20061069847705, -33.886918725260998], [151.200620164862698, -33.886467994010133].....

```

However, when I write the file to Elasticsearch, inspired from this link:  
[How to index geojson file in elasticsearch?](https://stackoverflow.com/questions/40129634/how-to-index-geojson-file-in-elasticsearch)

```
def geojson2es(gj):
    for feature in gj['features']:
        yield feature

with open(input_path+'/'+ data) as f:
    gj = json.load(f)

    es = Elasticsearch(hosts=[{'host': 'localhost', 'port': 9200}])

    k = [{
        "_index": "test",
        "_source": feature,
    } for feature in geojson2es(gj)]

    helpers.bulk(es, k)

```

I have got this error:

**{'type': 'mapper\_parsing\_exception', 'reason': 'failed to parse field [geometry.coordinates] of type [geo\_shape]', ' caused\_by': {'type': 'parse\_exception', 'reason': 'shape must be an object consisting of type and coordinates'}}**

Did anyone encounter a similar issue? How can I fix it?

---

<div class="post-metadata">

**Author:** ![Ignacio\_Vera](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ignacio_vera/32/36674_2.png) [@Ignacio\_Vera](https://discuss.elastic.co/u/Ignacio_Vera)\
**Post date:** [June 2, 2020, 7:48am UTC](https://discuss.elastic.co/t/geojson-to-elasticsearch-failed-to-parse-field-geometry-coordinates-of-type-geo-shape/235261/2 "2020-06-02T07:48:32Z")

</div>

Would it be possible to share a complete example that can reproduce the issue?

---

<div class="post-metadata">

**Author:** ![Scorpion21](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/scorpion21/32/48483_2.png) [@Scorpion21](https://discuss.elastic.co/u/Scorpion21)\
**Post date:** [June 2, 2020, 11:26pm UTC](https://discuss.elastic.co/t/geojson-to-elasticsearch-failed-to-parse-field-geometry-coordinates-of-type-geo-shape/235261/3 "2020-06-02T23:26:14Z")

</div>

Hi there,  
Thanks for following up.  
This issue has been fixed by correcting the mappings to:

```
{
  "mappings": {
    "properties": {
      "type": {
        "type": "keyword"
      },
      "properties": {
        "type": "object"
      },
      "geometry": {
        "type": "geo_shape"
      }
    }
  }
}
```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [June 30, 2020, 11:26pm UTC](https://discuss.elastic.co/t/geojson-to-elasticsearch-failed-to-parse-field-geometry-coordinates-of-type-geo-shape/235261/4 "2020-06-30T23:26:20Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
