我想对Elastic执行以下伪查询:
SELECT SomeTypeOfObjects WHERE distance to
PointOfInterests < 20km AND PointOfInterests.type = 'bar';
我在Elastic中有以下数据:
SomeTypeOfObjects (around 10.000.000 rows)
----------
id = x
geo_location = x,x
PointOfInterests( around 400.000 rows )
---------
id = x
geo_location = x,x
type=bar, hospital, etc
如果没有2个查询或向查询提供所有可能的地理位置,这是否可能?
最佳答案
如果您将经纬度另存为geo-point,则应该能够执行 geo_distance
查询,如下所示:
GET /my_locations/location/_search
{
"query": {
"bool" : {
"must" : {
"match_all" : {}
},
"filter" : {
"geo_distance" : {
"distance" : "12km",
"pin.location" : {
"lat" : 40,
"lon" : -70
}
}
}
}
}
}
显然无法回答您的问题。我想最好的选择是
1.获取所有条形的坐标
2.对多个点使用geo_distance:
https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-geo-distance-query.html
关于elasticsearch - Elasticsearch过滤器在Poi附近,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48564871/