4

我在 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": {}
      }
    }
  }
}
4

1 回答 1

7

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

{
  "query": {
    "filtered": {
      "filter": {
        "geo_shape": {
          "boundaries": {
            "relation": "intersects",
            "shape": {
              "coordinates": [
                -96.960876,
                32.795025
              ],
              "type": "point"
            }
          }
        }
      },
      "query": {
        "match_all": {}
      }
    }
  }
}
于 2014-08-15T16:09:56.697 回答