本文介绍了如何在elsaticsearch中编写映射,以获得具有纬度和高度的地理点?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
My_Json_File
{
"addressInfo": {
"city": "Wimsheim",
"postcode": "71299",
"geopoint": {
"lon": 48.845877,
"lat": 8.821861,
"alt": 0.0
}
},
"_id": "ac169008-aa5b-4b09-aa9e-3bf3018f316d"
}
- 请提供关于如何在地理点和
- Pls give suggestion on how encounter this "alt" field in geopoint and "_id" field and also write a suitable mappings for above JSON file.
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,它为地理点字段的进一步操作提供了许多其他选项。
On your place I would move "alt" out of geopoint and use mapping type "geo_point" which provides a lot of other options for further operations on geopoint field.
它看起来像:
{ "_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类型字段接收数据,如:
where geo_point type field receives data like:
{"lat": 8.821861, "lon": 48.845877}
这篇关于如何在elsaticsearch中编写映射,以获得具有纬度和高度的地理点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!