文章目录
前言
最近除了再用es的基础全文查询外,也频繁用到了ES的地理位置查询与特殊查询,故而再次记录一下。
一、地理位置查询
1、点位距离查询:geo_distance query
例如:给出一个中心点,查询距离该中心点指定范围内的文档:
GET /address_point/_search
{
"query": {
"bool": {
"must": [
{
"match_all": {
}
}
],
"filter": [
{
"geo_distance": {
"distance": "600km",
"location": {
"lat": 34.288991,
"lon": 108.940429
}
}
}
]
}
}
}
查询以(34.288991,108.940429) 为圆心,以 600KM 为半径,这个范围内的数据。
2、矩形面内查询:geo_bounding_box query
在某一个矩形内的点,通过两个点锁定一个矩形:
GET /address_point/_search
{
"query": {
"bool": {
"must": [
{
"match_all": {
}
}
],
"filter": [
{
"geo_bounding_box": {
"location": {
"top_left": {
"lat": 32.0639555946604,
"lon": 118.78967285156249
},
"bottom_right": {
"lat": 29.98824461550903,

最低0.47元/天 解锁文章
778

被折叠的 条评论
为什么被折叠?



