0

我想将我的数据从sql移动到elasticsearch。 我每次尝试添加多边形时都有例外。不能将地理形状插入elasticsearch

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

坐标建立(在C#):

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

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

有两个例外:

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

MapperParsingException[failed to parse [GEOMETRIES.SHAPE]]; nested: InvalidShapeException[provided shape has duplicate consecutive coordinates at: (number, number, NaN)]; 

回答

0

我解决它。

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

InvalidShapeException是因为一些多边形的基本上都是一条线,elasticsearch不喜欢

最终双方犯下了错误,因为我得到的多边形是搞砸