我在ES中有一个"boundaries"字段的文档。下面是字段内容的示例:https://gist.github.com/litzinger/a95342dedc0081c8db8d
给定一个经纬度点,我需要能够查询该索引以查找该点属于哪个文档。我在构造这个查询时遇到了麻烦,似乎找不到一个明确的例子来说明如何在任何地方做到这一点。
这是我的一个查询的例子,其中坐标数组是lon/lat点。我已经有一个工作查询,将使用一个多边形来查找所有文档,有一个lon/lat点,但我似乎不能让它工作的另一种方式。
{
"query": {
"filtered": {
"filter": {
"geo_shape": {
"boundaries": {
"relation": "intersects",
"shape": {
"coordinates": [
[
[-96.960876,32.795025]
]
],
"type": "point"
}
}
}
},
"query": {
"match_all": {}
}
}
}
}
明白了。首先,我的映射是错误的。这个领域被称为"边界",而不是"边界"。哦。第二,座标值错误。搜索查询应该是:
{
"query": {
"filtered": {
"filter": {
"geo_shape": {
"boundaries": {
"relation": "intersects",
"shape": {
"coordinates": [
-96.960876,
32.795025
],
"type": "point"
}
}
}
},
"query": {
"match_all": {}
}
}
}
}