Elasticsearch版本: 6.5.0
我有关于geo_shape点搜索的问题,它看起来很简单,但我不明白为什么..如果你有任何想法,我将不胜感激..
我的索引模式映射:
{
"fullname": {
"type": "text"
},
"location": {
"type": "geo_shape"
}
}我创建了这个文档,其中包含三个5 km的圆。(阿根廷、印度和伦敦)
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“?
如有任何建议,欢迎光临。
非常感谢。
发布于 2020-04-22 17:41:16
无法使用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并共享响应。
https://stackoverflow.com/questions/61355247
复制相似问题