1

我正在尝试使用弹性搜索的地理边界框功能在我选择的框中返回结果。我从谷歌地图获得边界坐标,它是东北和西南格式。

这是传递给 elasticsearch php 客户端的参数的示例转储(为了便于阅读,已转换为 JSON):

{
   "index":"MyIndex",
   "body":{
      "query":{
         "bool":{
            "must":{
               "match_all":{

               }
            },
            "filter":{
               "geo_bounding_box":{
                  "location":{
                     "top_right":{
                        "lat":53.2323104,
                        "lon":6.704821
                     },
                     "bottom_left":{
                        "lat":52.3136724,
                        "lon":4.311799
                     }
                  }
               }
            }
         }
      }
   }
}

这是 ES 中的一些示例结果,当我进行普通的简单搜索(无地理/边界框)时,我会返回:

[
   {
      "object_id":14396,
      "object_type":"POI",
      "location":{
         "lat":53.05194,
         "lon":5.38417
      }
   },
   {
      "object_id":24046,
      "object_type":"POI",
      "location":{
         "lat":52.52711,
         "lon":5.06319
      }
   },
   {
      "object_id":24680,
      "object_type":"POI",
      "location":{
         "lat":52.72525,
         "lon":4.96201
      }
   }
]

我相信这些都应该由边界框搜索返回,我在这里缺少什么?

编辑:包括下面的映射

{
   "MyIndex":{
      "mappings":{
         "pois":{
            "properties":{
               "object_id":{
                  "type":"string"
               },
               "object_type":{
                  "type":"string"
               },
               "location":{
                  "type":"geo_point"
               },
            }
         },
      }
   }
}

编辑 2:在 ES 中使用数据的原始响应:

{
   "_index":"MyIndex",
   "_type":"pois",
   "_id":"14916",
   "_score":1,
   "_source":{
      "object_id":"14916",
      "object_type":"POI",
      "location":{
         "lat":53.13915,
         "lon":6.19422
      }
   }
}
4

1 回答 1

-1

和值被错误top_leftbottom_right传递。尝试将值设置如下:

location :{
    "top_right":{
        "lat":53.2323104,
        "lon":4.311799
        },
    "bottom_left":{
        "lat":52.3136724,
        "lon":6.704821
        }
}
于 2019-11-19T07:06:23.223 回答