elasticsearch - Elasticsearch geo_shape 点搜索返回错误的geometrycollection 文档
问题描述
弹性搜索版本:6.5.0
我对 geo_shape 点搜索有疑问,它看起来很简单,但我不明白为什么..我会很感激任何想法..
我的索引架构映射:
{
"fullname": {
"type": "text"
},
"location": {
"type": "geo_shape"
}
}
我创建了包含三个 5 公里圆圈的文档。(阿根廷、印度和伦敦)
PUT /location_test/region/doc123456
{
"fullname": "Argentina, India and London",
"location": {
"geometries": [
{
"coordinates": [
-58.4358666,
-34.5884887
],
"type": "circle",
"radius": "5.0km"
},
{
"coordinates": [
72.8457919,
19.1045692
],
"type": "circle",
"radius": "5.0km"
},
{
"coordinates": [
-0.1436263,
51.5412567
],
"type": "circle",
"radius": "5.0km"
}
],
"type": "geometrycollection"
}
}
当我使用以下查询搜索南安普敦的一个点(lat=50.909594,long=-1.404098)时:
GET location_test/_search
{
"query": {
"geo_shape": {
"location": {
"shape": {
"type": "point",
"coordinates": [
-1.404098,
50.909594
]
}
}
}
}
}
但是我拿回了文档 doc123456,这没有任何意义,因为阿根廷、印度和伦敦离南安普顿很远。它不应与查询匹配,并且不应返回任何结果。
有趣的是,然后我更新了上面的文档,(删除了一个圆圈,阿根廷),现在,该文档只包含印度和伦敦圈子。
运行相同的查询,我没有得到结果,这是正确的。
为什么包含这三个圆圈的文档有错误的结果?
我是否正确使用了正确的映射和字段类型“geometrycollection”?
任何建议表示赞赏。
非常感谢您。
解决方案
无法使用 6.6.0 复制此内容:
PUT location_test
{"mappings":{"region":{"properties":{"fullname":{"type":"text"},"location":{"type":"geo_shape","strategy":"recursive"}}}}}
POST /location_test/region/doc123456
{"fullname":"Argentina, India and London","location":{"geometries":[{"coordinates":[-58.4358666,-34.5884887],"type":"circle","radius":"5.0km"},{"coordinates":[72.8457919,19.1045692],"type":"circle","radius":"5.0km"},{"coordinates":[-0.1436263,51.5412567],"type":"circle","radius":"5.0km"}],"type":"geometrycollection"}}
GET location_test/_search
{
"query": {
"geo_shape": {
"location": {
"shape": {
"type": "point",
"coordinates": [
-1.404098,
50.909594
]
}
}
}
}
}
0 次点击——人们所期望的。
尝试运行GET location_test/_search?explain=true
并分享响应。
推荐阅读
- java - getResource("path") 在 Intellij 中有效,但在 jar 文件中无效
- c++ - 按下数字和数字键时无法在 Qt C++ 中处理 QKeyEvent
- angularjs - 下拉菜单和访问 ng-repeat 之外的元素的 AngularJS 问题
- linux - ROP 利用:写入 .data 部分 SIGSEGV
- php - 表单重定向到不存在的页面 wordpress
- html - 为什么我的 gif 在 Firefox 中像素化,而不是在 google chrome 浏览器中?
- php - 为 2 个不同的网站提供相同的登录详细信息
- asp.net-core - .net core 2.0 - 值不能为空。参数名称:key
- json - 喷雾 JSON 无法序列化案例类
- python - 基于数组的 MinHeap