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不喜歡

最終雙方犯下了錯誤,因爲我得到的多邊形是搞砸