简体   繁体   English

弹性搜索地理边界框不返回结果

[英]elasticsearch geo bounding box not returning results

I'm trying to use the Geo Bounding Box functionality of elastic search to return results in my box of choice.我正在尝试使用弹性搜索的地理边界框功能在我选择的框中返回结果。 I get the boundary coordinates from Google Maps, and it's in the NorthEast and SouthWest format.我从谷歌地图得到边界坐标,它是东北和西南格式。

This is an example dump of the parameters passed to the elasticsearch php client (converted to JSON for readability):这是传递给 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
                     }
                  }
               }
            }
         }
      }
   }
}

Here a few example results that are in ES and I get returned when I do a normal simple search (no geo/bounding box):这里有一些 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
      }
   }
]

I believe these should all be returned by the bounding box search, what am I missing here?我相信这些都应该由边界框搜索返回,我在这里错过了什么?

Edit: Included mapping below编辑:包括下面的映射

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

Edit 2: Raw response with data in ES:编辑 2:原始响应与 ES 中的数据:

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

The top_left and bottom_right values are incorrectly passed. top_leftbottom_right值被错误地传递。 Try to the set the values as following:尝试设置如下值:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM