【问题标题】:Elasticsearch filter where poi nearbyElasticsearch 过滤附近的 poi
【发布时间】:2018-02-01 14:17:54
【问题描述】:

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

【问题讨论】:

    标签: elasticsearch elasticsearch-6


    【解决方案1】:

    如果您将 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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-04-18
      • 2012-06-20
      • 2023-04-02
      • 2015-09-02
      • 1970-01-01
      • 1970-01-01
      • 2013-04-02
      相关资源
      最近更新 更多