如何在 elasticsearch 中为具有 lat lon 和 alt 的地理点编写映射?
How to write mappings in elsaticsearch for geopoint having lat lon and alt?
My_Json_File
{
"addressInfo": {
"city": "Wimsheim",
"postcode": "71299",
"geopoint": {
"lon": 48.845877,
"lat": 8.821861,
"alt": 0.0
}
},
"_id": "ac169008-aa5b-4b09-aa9e-3bf3018f316d"
}
- 请就如何在 geopoint 和 "_id" 字段中遇到此 "alt" 字段提出建议,并编写合适的映射JSON 文件上方。
更新 1
My_Json_File
{
"_id": "ac169008-aa5b-4b09-aa9e-3bf3018f316d"
"addressInfo": {
"city": "Wimsheim",
"postcode": "71299",
"geopoint": {
"lon": 48.845877,
"lat": 8.821861,
"alt": 0.0
}
},
"prices": [{
"fuelType": "DIESEL",
"price": "52.09"
}, {
"fuelType": "PETROL",
"price": "66.20"
},{
"fuelType": "AUTOGAS",
"price": "66.20"
}]
}
在你的地方,我会将 "alt" 移出地理点并使用映射类型 "geo_point",它为对地理点字段的进一步操作提供了许多其他选项。
看起来像:
{
"_id": "ac169008-aa5b-4b09-aa9e-3bf3018f316d"
"addressInfo": {
"city": "Wimsheim",
"postcode": "71299",
"geopoint": {
"lon": 48.845877,
"lat": 8.821861,
},
"alt": 0.0
},
}
映射应如下所示:
"properties": {
"_id": {
"type": "string"
},
"addressInfo": {
"type": "nested",
"properties": {
"city": {
"type": "string",
},
"postcode": {
"type": "integer",
},
"alt": {
"type": "float",
},
"geopoint": {
"type": "geo_point",
},
},
},
},
其中 geo_point 类型字段接收如下数据:
{"lat": 8.821861, "lon": 48.845877}
My_Json_File
{
"addressInfo": {
"city": "Wimsheim",
"postcode": "71299",
"geopoint": {
"lon": 48.845877,
"lat": 8.821861,
"alt": 0.0
}
},
"_id": "ac169008-aa5b-4b09-aa9e-3bf3018f316d"
}
- 请就如何在 geopoint 和 "_id" 字段中遇到此 "alt" 字段提出建议,并编写合适的映射JSON 文件上方。
更新 1
My_Json_File
{
"_id": "ac169008-aa5b-4b09-aa9e-3bf3018f316d"
"addressInfo": {
"city": "Wimsheim",
"postcode": "71299",
"geopoint": {
"lon": 48.845877,
"lat": 8.821861,
"alt": 0.0
}
},
"prices": [{
"fuelType": "DIESEL",
"price": "52.09"
}, {
"fuelType": "PETROL",
"price": "66.20"
},{
"fuelType": "AUTOGAS",
"price": "66.20"
}]
}
在你的地方,我会将 "alt" 移出地理点并使用映射类型 "geo_point",它为对地理点字段的进一步操作提供了许多其他选项。
看起来像:
{
"_id": "ac169008-aa5b-4b09-aa9e-3bf3018f316d"
"addressInfo": {
"city": "Wimsheim",
"postcode": "71299",
"geopoint": {
"lon": 48.845877,
"lat": 8.821861,
},
"alt": 0.0
},
}
映射应如下所示:
"properties": {
"_id": {
"type": "string"
},
"addressInfo": {
"type": "nested",
"properties": {
"city": {
"type": "string",
},
"postcode": {
"type": "integer",
},
"alt": {
"type": "float",
},
"geopoint": {
"type": "geo_point",
},
},
},
},
其中 geo_point 类型字段接收如下数据:
{"lat": 8.821861, "lon": 48.845877}