1

我想在 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 个查询或向查询提供所有可能的地理位置,这是否可行?

4

1 回答 1

0

如果您将 lat,lon 保存为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

于 2018-02-02T08:31:21.803 回答