地理点距离的弹性搜索查询

elastic search query for geo points distance

我想按客户点获取配送半径内的资源。 我的映射如下所示:

 "restaurantPoint"       => [
 "type" => "geo_point"
 ],
 "deliveryRadius"        => [
 "type" => "float"
 ]

和示例数据如下:

`"restaurantPoint": "35.73701996471125,51.409086138010025",
"deliveryRadius": 1`

因此,每个餐厅都有一个点和以公里为单位的送货半径,另一方面我们知道用户点。 在查询中,我想获得可以将食物运送到用户位置的餐厅。 我必须检查餐厅点和用户点之间的距离是否小于等于餐厅送货半径。

例如,如果用户和餐厅之间的距离为 1 公里,餐厅送货半径为 2 公里,我们可以select。

elastic search文档不全,求解决方法

最后我使用了脚本:

GET development-restaurants/restaurants/_search
{
    "query": {
        "bool" : {
        "must" : {
            "script" : {
                "script" : {
                    "source": "doc['restaurantPoint'].arcDistance(35.73702, 51.40909) <= doc['deliveryRadius'].value",
                    "lang": "painless"
                 }
            }
        }
     }
  }
}