【发布时间】:2020-05-12 06:20:37
【问题描述】:
我正在将业务添加到 ElasticSearch。有些是地理定位(经度、纬度坐标),有些是仅在线业务(无坐标)。
我要做的是创建一个查询,在其中过滤具有给定地理位置和半径的企业。我想包括那些在线业务(没有地理坐标)。
你有什么想法吗?
我试过了:
GET /organizations/_search
{
"query": {
"bool" : {
"must_not": {
"exists": {
"field": "geocoords"
}
},
"filter" : {
"geo_distance" : {
"distance" : "200km",
"geocoords" : {
"lon": -73.57,
"lat": 45.45
}
}
}
}
}
}
但我没有得到结果:
{
"took" : 5,
"timed_out" : false,
"_shards" : {
"total" : 1,
"successful" : 1,
"skipped" : 0,
"failed" : 0
},
"hits" : {
"total" : {
"value" : 0,
"relation" : "eq"
},
"max_score" : null,
"hits" : [ ]
}
}
这是我拥有的数据:
{
"took" : 1,
"timed_out" : false,
"_shards" : {
"total" : 1,
"successful" : 1,
"skipped" : 0,
"failed" : 0
},
"hits" : {
"total" : {
"value" : 1,
"relation" : "eq"
},
"max_score" : 1.0,
"hits" : [
{
"_index" : "organizations",
"_type" : "_doc",
"_id" : "2",
"_score" : 1.0,
"_source" : {
"is_active" : true,
"name": "Compagny Inc.",
"geocoords" : {
"lon" : -73.5761003,
"lat" : 45.4560316
}
}
}
]
}
}
任何提示或建议?谢谢。
【问题讨论】: