首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Elasticsearch geo_shape点搜索返回错误的几何集合文档

Elasticsearch geo_shape点搜索返回错误的几何集合文档
EN

Stack Overflow用户
提问于 2020-04-22 08:09:13
回答 1查看 109关注 0票数 1

Elasticsearch版本: 6.5.0

我有关于geo_shape点搜索的问题,它看起来很简单,但我不明白为什么..如果你有任何想法,我将不胜感激..

我的索引模式映射:

代码语言:javascript
复制
{
    "fullname": {
        "type": "text"
    },
    "location": {
      "type": "geo_shape"
    }
}

我创建了这个文档,其中包含三个5 km的圆。(阿根廷、印度和伦敦)

代码语言:javascript
复制
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):

代码语言:javascript
复制
GET location_test/_search
{
  "query": {
    "geo_shape": {
      "location": {
        "shape": {
          "type": "point",
          "coordinates": [
            -1.404098,
            50.909594
          ]
        }
      }
    }
  }
}

但我拿到了doc123456文档,这没有任何意义,因为阿根廷、印度和伦敦都离南安普敦很远。它不应与查询匹配,并且不应返回任何结果。

有趣的是,然后我更新了上面的文档,(删除其中一个圆圈,阿根廷),现在,文档只包含印度和伦敦的圆圈。

运行相同的查询,我没有得到结果,这是正确的。

为什么包含这三个圆圈的文档会有错误的结果?

我是否正确使用了映射和字段类型"geometrycollection“?

如有任何建议,欢迎光临。

非常感谢。

EN

回答 1

Stack Overflow用户

发布于 2020-04-22 17:41:16

无法使用6.6.0复制此文件:

代码语言:javascript
复制
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并共享响应。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/61355247

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档