0

I am trying to move my data from sql to elasticsearch. I have an exception every time i try adding a polygon shape.

I use WktReader to read the WKT and add it in a JeoJson class. The class contains type (polygon) and coordinates

coordinates build (in c#):

{ [ [ [ x,y ], [ x,y ], [ x,y ], [ x,y ], [ x,y ] ] ] }

GEOMETRIES mapping in elasticsearch:

"GEOMETRIES" : {
    "type" : "nested",
    "properties" : {
        "AREA" : { "type" : "double" },
        "CENTROID" : {
            "type" : "geo_point",
            "geohash" : true,
            "geohash_preflix" : true
        },
        "KEY" : {
            "type" : "string",
            "index" : "not_analyzed"
        },
        "SHAPE" : {
            "type" : "geo_shape"
        }
    }
}

There are two exceptions:

1

MapperParsingException[failed to parse [GEOMETRIES.SHAPE]]; nested: IllegalArgumentException[Invalid number of points in LinearRing (found 3 - must be 0 or >= 4)];

2

MapperParsingException[failed to parse [GEOMETRIES.SHAPE]]; nested: InvalidShapeException[provided shape has duplicate consecutive coordinates at: (number, number, NaN)];
Kumar Saurabh
  • 2,297
  • 5
  • 29
  • 43
Meinhh
  • 51
  • 1
  • 1
  • 6

1 Answers1

0

I solved it.

IllegalArgumentException was because the polygons first and last coord was the centroid and only the second and the one before last were the real first and last point. all I did was to delete the first and last points.

InvalidShapeException was because the some of the polygons are basically a line and elasticsearch doesn't like it

In the end both the mistakes were because The polygons I got were messed up

Meinhh
  • 51
  • 1
  • 1
  • 6