0

我面临一个问题,我知道如何找到特定半径内的所有 geo_points,但我需要找到一个特定点所在的区域或 geo_shape。为了解决这个问题,我制作了以下索引:

PUT /users

而这个映射:

PUT /users/_mapping/_doc
{
    "properties": {
        "radius": {
          "type": "geo_shape",
          "tree": "quadtree",
          "precision": "100m"
        },
        "point":{
          "type":"geo_point"
        }
      }

}

以下是示例文档:

POST /users/_doc
{
    "radius":{
      "type" : "circle",
      "coordinates" : [28.363157, 77.287550],
      "radius" : "100km"
    },
    "point":{
      "lat" : 28.363157,
      "lon": 77.287550
    }

}

我正在做的查询是:

POST /users/_search
{
    "query":{
        "bool": {
            "must": {
                "match_all": {}
            },
            "filter": {
                "geo_shape": {
                    "radius": {
                        "shape": {
                            "type": "point",
                            "coordinates" : [29.363157, 77.28755]
                        },
                        "relation": "contains"
                    }
                }
            }
        }
    }
}

现在,查询中的 latlongs 和 doc 之间的距离几乎是 110-112kms,因此上面的查询返回确切的结果,但是当我查询时[30.363157, 77.28755],即使距离超过 220kms,它仍然返回文档。

我究竟做错了什么?

4

0 回答 0