文章目录
我们以地图资源分为两类 医院&景点
Mapping
三种定义位置的方式
- “location”: {“lon”:116.403103,“lat”:39.923973}
- “location”: [116.403103,39.923973]
- “location”:“POINT (116.402888 39.932605)”
PUT /example
{
"mappings": {
"properties": {
"location": {
"type": "geo_point"
},
"name":{
"type": "text"
},
"class":{
"type":"keyword"
}
}
}
}
POST /example/_bulk
{
"index":{
} }
{
"name": "故宫","class":"景点", "location": {
"lon":116.403103,"lat":39.923973}}
{
"index":{
} }
{
"name": "天安门","class":"景点", "location": [116.403103,39.923973] }
{
"index":{
} }
{
"name": "景山","class":"景点", "location":"POINT (116.402888 39.932605)" }
{
"index"

本文介绍了如何在Elasticsearch中使用Geo-boundingbox进行矩形范围查询,Geo-distance进行距离计算,以及Geo-polygon进行多边形区域查询。实例演示了医院和景点的位置管理及范围统计技巧。
最低0.47元/天 解锁文章
3575





