假设我有多个文档,如下所示(取自geo_shape
的ElasticSearch文档):
{
"name": "Some Neighborhood",
"location" : {
"type" : "polygon",
"coordinates" : [
[ [100.0, 0.0], [101.0, 0.0], [101.0, 1.0], [100.0, 1.0], [100.0, 0.0] ]
]
}
}
我是否可以使用任何查询,给定一个点,返回包含该点的文档?换句话说,考虑到一点,我试图快速找出它所在的邻居。还有其他更好的东西吗?
答案 0 :(得分:1)
您可以这样查询:
GET /my_index/landmark/_search
{
"query": {
"filtered": {
"query": {
"match_all": {}
},
"filter": {
"geo_shape": {
"location": {
"shape": {
"type": "point",
"coordinates" : [4.896863,52.374409]
}
}
}
}
}
}
}