【问题标题】:How to find documents containing polygons by point?如何按点查找包含多边形的文档?
【发布时间】:2014-10-09 07:50:38
【问题描述】:

我在 ES 中有具有“边界”字段的文档。这是字段内容的示例:https://gist.github.com/litzinger/a95342dedc0081c8db8d

给定一个 lon/lat 点,我需要能够查询该索引以找到该点所在的文档。我在构建此查询时遇到问题,似乎无法在任何地方找到一个明确的示例来说明如何执行此操作。

这是我的一个查询示例,其中坐标数组是 lon/lat 点。我已经有一个工作查询,它​​将使用一个多边形来查找所有具有 lon/lat 点的文档,但我似乎无法让它以相反的方式工作。

{
  "query": {
    "filtered": {
      "filter": {
        "geo_shape": {
          "boundaries": {
            "relation": "intersects",
            "shape": {
              "coordinates": [
                [
                  [-96.960876,32.795025]
                ]
              ],
              "type": "point"
            }
          }
        }
      },
      "query": {
        "match_all": {}
      }
    }
  }
}

【问题讨论】:

    标签: elasticsearch elastica


    【解决方案1】:

    想通了。首先,我的映射是错误的。该领域被称为“边界”而不是“边界”。哎呀。二是坐标值错误。搜索查询应该是:

    {
      "query": {
        "filtered": {
          "filter": {
            "geo_shape": {
              "boundaries": {
                "relation": "intersects",
                "shape": {
                  "coordinates": [
                    -96.960876,
                    32.795025
                  ],
                  "type": "point"
                }
              }
            }
          },
          "query": {
            "match_all": {}
          }
        }
      }
    }
    

    【讨论】:

    • 我正在尝试 sam 的东西,但使用“WITHIN”但它不起作用,任何帮助。
    猜你喜欢
    • 2020-03-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-12-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-04-23
    相关资源
    最近更新 更多