geolocation
Elasticsearch offers two ways of representing geolocations: latitude-longitude points using the geo_point
field type, and complex shapes defined in GeoJSON, using the geo_shape
field type.
ES用两种方式代表geolocation,数据类型为geo_point的经纬坐标点,或者数据类型为geo_shape定义的geoJSON复杂的图形
PUT /attractionsgeo-points不能被自动识别。所以必须通过mapping指定
{
"mappings": {
"restaurant": {
"properties": {
"name": {
"type": "string"
},
"location": {
"type": "geo_point"
}
}
}
}
}
PUT /attractions/restaurant/1
{
"name": "Chipotle Mexican Grill",
"location": "40.715, -74.011"location的格式化顺序为维度,经度
}
PUT /attractions/restaurant/2
{
"name": "Pala Pizza",
"location": {推荐使用这个,不容易弄混啊~~~
"lat": 40.722,
"lon": -73.989
}
}
PUT /attractions/restaurant/3
{
"name": "Mini Munchies Pizza",
"location": [ -73.983, 40.719 ]经度,纬度
}