无法将地理形状插入弹性搜索

时间:2015-11-25 10:03:01

标签: c# elasticsearch illegalargumentexception wkt elasticsearch-geo-shape

我正在尝试将数据从sql移动到elasticsearch。 每次尝试添加多边形时都会出现异常。

我使用WktReader读取WKT并将其添加到JeoJson类中。 该类包含类型(多边形)和坐标

坐标构建(在c#中):

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

在elasticsearch中的GEOMETRIES映射:

"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"
        }
    }
}

有两个例外:

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)];

1 个答案:

答案 0 :(得分:0)

我解决了。

IllegalArgumentException是因为多边形的第一个和最后一个坐标是质心,只有第二个和前一个是真正的第一个和最后一个点。我所做的只是删除第一个和最后一个点。

InvalidShapeException是因为一些多边形基本上是一条线而弹性搜索不喜欢它

最后两个错误都是因为我得到的多边形搞砸了

相关问题