geojson to Elasticsearch : Unable to Tessellate shape

1.7k Views Asked by At

I am indexing some geojson file (around 4000 ~ 5000 multi-polygon features) into Elasticsearch.

Here is the mappings

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

My code for indexing looks like this:

helpers.bulk(es, k, chunk_size=500, request_timeout=1000)

The indexing action (in chunk) is stopped by this error message:

{'type': 'mapper_parsing_exception', 'reason': 'failed to parse field [geometry] of type [geo_shape]', 'caused_by': {'type': 'illegal_argument_exception', 'reason': 'Unable to Tessellate shape

What is the cause of this error?
Can I ignore this error when indexing geojson files?

3

There are 3 best solutions below

9
Joe - Check out my books On BEST ANSWER

Your geojson is syntactically correct & valid. Now you just need to make sure that you index your multi-polygons properly:

PUT demo_l08_bs
{
  "mappings": {
    "properties": {
      "geometry": {
        "type": "geo_shape"
      }
    }
  }
}

Index the geojson w/o changing anything:

POST demo_l08_bs/_doc
{
  "properties": {
    ...
  },
  "geometry": {
    "type": "MultiPolygon",
    "coordinates": [...]
  }
}

Verify a point lies within it:

GET demo_l08_bs/_search
{
  "query": {
    "geo_shape": {
      "geometry": {
        "shape": {
          "type": "point",
          "coordinates": [
            151.14646911621094,
            -33.68463933764522
          ]
        },
        "relation": "intersects"
      }
    }
  }
}

enter image description here

6
Ignacio Vera On

I had a look into the issue and the polygon is valid and uncover a bug in Lucene tessellator. I opened an issue:

https://issues.apache.org/jira/browse/LUCENE-9417

And the fix is here:

https://github.com/apache/lucene-solr/pull/1614

0
Scorpioooooon21 On

I am not sure if this error was caused by some complicated multi-polygons in the input file.

However, after converted multi-ploygons into individual polygons inspired by the below post, I managed to ingest all shapes without any error :)

https://gist.github.com/mhweber/cf36bb4e09df9deee5eb54dc6be74d26