1、首先创建mapping
PUT test
{
"mappings": {
"test":{
"properties": {
"location":{
"type": "geo_point"
}
}
}
}
}
2、导入数据
POST test/test
{
"location":{
"lat":12,
"lon":24
}
}
3、查询
1)根据给定两个点组成的矩形,查询矩形内的点
GET test/test/_search
{
"query": {
"geo_bounding_box": {
"location": {
"top_left": {
"lat": 28,
"lon": 10
},
"bottom_right": {
"lat": 10,
"lon": 30
}
}
}
}
}
2)根据给定的多个点组成的多边形,查询范围内的点
GET test/test/_search
{
"query": {
"geo_polygon": {
"location": {
"poi