我正在嘗試使用 Python 將 geojson 文件索引到 elasticsearch(版本 7.6.2)中。這是我在 elasticsearch 中定義的映射。'mappings': { "properties": { "geometry": { "properties": { "coordinates": { "type": "geo_shape" }, "type": { "type": "text", "fields": { "keyword": { "type": "keyword", "ignore_above": 256 } } } } }, }}geojson 文件如下所示:{"type": "FeatureCollection","name": "testting","crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:OGC:1.3:CRS84" } },"features": [{ "type": "Feature", "properties": { "LEGEND": "x_1", "THRESHOLD": -109, "COLOR": "0 0 255", "Prediction": "Coverage" }, "geometry": { "type": "MultiPolygon", "coordinates": [ [ [ [ 151.20061069847705, -33.886918725260998 ], [ 151.200620164862698, -33.886467994010133 ].....但是,當我將文件寫入 Elasticsearch 時,受到此鏈接的啟發:def geojson2es(gj): for feature in gj['features']: yield featurewith open(input_path+'/'+ data) as f: gj = json.load(f) es = Elasticsearch(hosts=[{'host': 'localhost', 'port': 9200}]) k = [{ "_index": "test", "_source": feature, } for feature in geojson2es(gj)] helpers.bulk(es, k)我有這個錯誤:{'type': 'mapper_parsing_exception', 'reason': '未能解析 [geo_shape] 類型的字段 [geometry.coordinates]', 'caused_by': {'type': 'parse_exception', 'reason': 'shape must是一個由類型和坐標組成的對象'}}有人遇到過類似的問題嗎?我該如何解決?
geojson 到 Elasticsearch:無法解析 [geo_shape] 類型的字段
慕的地6264312
2022-12-20 11:16:57