创建索引库
PUT http://localhost:9200/geo
{
"mappings": {
"poi": {
"properties": {
"name": {
"type": "string"
},
"location": {
"type": "geo_shape"
}
}
}
}
}
录入数据
curl -POST http://localhost:9200/geo/poi
{
"name": "北京华通康源科技有限公司",
"location": {
"type": "point",
"coordinates": [116.65032,
40.33047]
}
}
curl -POST http://localhost:9200/geo/poi
{
"name": "北京城磊鑫伟业工贸有限公司",
"location": {
"type": "point",
"coordinates": [117.08914,
40.59023]
}
}
curl -POST http://localhost:9200/geo/poi
{
"name": "null",
"location": {
"type": "point",
"coordinates": [115.69617,
39.97179]
}
}
范围查询
{
"query":{
"bool": {
"must": {
"match_all": {}
},
"filter": {
"geo_shape": {
"location": {
"shape": {
"type": "envelope",
"coordinates" : [[111.0, 29.0], [117.0, 40.0]]
},
"relation": "within"
}
}
}
}
}
}