世界上并没有完美的程序,但是我们并不因此而沮丧,因为写程序就是一个不断追求完美的过程。
问:geo_bounds有什么特点?
答:
问:geo_bounds如何使用?
答:
DELETE /geo_bounds_test
PUT /geo_bounds_test
{
"mappings": {
"properties": {
"geo_point": {"type": "geo_point"}
}
}
}
POST /geo_bounds_test/_bulk
{"index": {"_id": 1}}
{"geo_point": [23, 45]}
{"index": {"_id": 2}}
{"geo_point": [58, 47]}
{"index": {"_id": 3}}
{"geo_point": [77, 44]}
{"index": {"_id": 4}}
{"geo_point": [66, 55]}
GET /geo_bounds_test/_search?size=0
{
"aggs": {
"geo_bounds_aggs": {
"geo_bounds": {
"field": "geo_point"
}
}
}
}
# 结果
{
"took" : 640,
"timed_out" : false,
"_shards" : {
"total" : 1,
"successful" : 1,
"skipped" : 0,
"failed" : 0
},
"hits" : {
"total" : {
"value" : 4,
"relation" : "eq"
},
"max_score" : null,
"hits" : [ ]
},
"aggregations" : {
"geo_bounds_aggs" : {
"bounds" : {
"top_left" : {
"lat" : 54.999999990686774,
"lon" : 22.999999970197678
},
"bottom_right" : {
"lat" : 43.99999997578561,
"lon" : 76.99999993667006
}
}
}
}
}



