gpt4 book ai didi

elasticsearch - 无法将GeoJSON与Elasticsearch 5和Kibana 5一起使用

转载 作者:行者123 更新时间:2023-12-02 22:19:36 25 4
gpt4 key购买 nike

我无法在Elasticsearch中为GeoJSON数据建立索引并使用它们创建Tile Map。

->将GeoJSON发送到ES:

curl -XPUT "http://localhost:9200/datas/data/3617" -d 
'{
"geometry": {
"coordinates": [
7.040691666666667,
43.626736111111114
],
"type": "Point"
},
"properties": {
"createdAt": {
"$date": "2016-04-06T15:40:42.402Z"
},
"device": "000-0002",
"ind": 0,
"timestamp": {
"$date": "2016-04-06T16:40:41.000Z"
}
},
"type": "Feature"
}'

检查映射

curl -XGET“ http://localhost:9200/datas/data/_mapping
{
"datas": {
"mappings": {
"data": {
"properties": {
"geometry": {
"properties": {
"coordinates": {
"type": "float"
},
"type": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
}
}
},
"properties": {
"properties": {
"createdAt": {
"properties": {
"$date": {
"type": "date"
}
}
},
"device": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"ind": {
"type": "long"
},
"timestamp": {
"properties": {
"$date": {
"type": "date"
}
}
}
}
},
"type": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
}
}
}
}
}
}

但是在Kibana中创建图块 map 时,在Kibana中出现以下错误:

“没有兼容的字段:“数据”索引模式不包含以下任何字段类型:geo_point”

我应该如何更改映射,以便在Tile Map中使用GeoJSON?

编辑1
curl -XPUT "http://localhost:9200/datas/_mapping/data" -d '{
"data": {
"properties": {
"geometry": {
"type": "geo_shape"
}
}
}
}'

=> {“确认”:true}
$ curl -XGET "http://localhost:9200/datas/_mapping/data"

=> {“数据”:{“映射”:{“数据”:{“属性”:{“几何”:{“类型”:“geo_shape”}}}}}}
curl -XPUT "http://localhost:9200/datas/data/3617" -d 
'{
"geometry": {
"coordinates": [
7.040691666666667,
43.626736111111114
],
"type": "Point"
},
}'

=> {“_index”:“数据”,“_ type”:“数据”,“_ id”:“3617”,“_ version”:1,“_ shards”:{“总计”:2,“成功”:1, “失败”:0},“创建”:true}

但是当我尝试创建平铺 map 时,出现此错误信息

Tile Map Error

在映射中将geo_shape替换为geo_point时,插入示例数据时出现以下错误:
curl -XPUT "http://localhost:9200/datas/data/3617" -d 
'{
"geometry": {
"coordinates": [
7.040691666666667,
43.626736111111114
],
"type": "Point"
},
}'

{"error":{"root_cause":[{"type":"parse_exception","reason":"field must be either [lat], [lon] or [geohash]"}],"type":"mapper_parsing_exception","reason":"failed to parse","caused_by":{"type":"parse_exception","reason":"field must be either [lat], [lon] or [geohash]"}},"status":400}

最佳答案

ES不会直接摄取GeoJSON,而是需要将其转换为适当的 geo_shape ,在您的情况下,它将是point

首先,您需要创建一个索引和一个映射以接受geo_shape字段,如下所示:

curl -XPUT "http://localhost:9200/datas" -d '{
"mappings": {
"data": {
"properties": {
"location": {
"type": "geo_shape"
}
}
}
}
}'

然后,您可以像下面这样索引您的GeoJSON点:
curl -XPUT "http://localhost:9200/datas/data/3617" -d '{
"location" : {
"type" : "point",
"coordinates" : [7.040691666666667, 43.626736111111114]
}
}'

更新

如果只需要容纳地理点,则使用 geo_point 而不是 geo_shape会更容易。
curl -XPUT "http://localhost:9200/datas" -d '{
"mappings": {
"data": {
"properties": {
"location": {
"type": "geo_point",
"geohash_prefix": true
}
}
}
}
}'

curl -XPUT "http://localhost:9200/datas/data/3617" -d '{
"location" : {
"lat": 43.626736111111114,
"lon": 7.040691666666667
}
}'

关于elasticsearch - 无法将GeoJSON与Elasticsearch 5和Kibana 5一起使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37587715/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com