【问题标题】:How to return geospatial distance results for geo_shapes in Elasticsearch如何在 Elasticsearch 中返回 geo_shapes 的地理空间距离结果
【发布时间】:2021-12-08 17:17:11
【问题描述】:

我有两个索引,都有超过 200 万个包含 localIds(映射到 keyword)和地理空间数据的文档。两个索引都使用geo_shape 作为映射),所以映射如下:

{
  "properties": {
    "localId": {
      "type": "keyword"
    },
    "geometry": {
      "type": "geo_shape"
    }
  }
}

我已经成功地对数据运行边界框查询,但我正在努力运行与点查询的距离。 The docs give explicit examples of the query running against geo_shape data,但我收到以下错误:

{
  "error" : {
    "root_cause" : [
      {
        "type" : "query_shard_exception",
        "reason" : "field [geometry] is not a geo_point field",
        "index_uuid" : "e7-HPZmUR4Wpu96W6K_YXw",
        "index" : "test1"
      }
    ],
    "type" : "search_phase_execution_exception",
    "reason" : "all shards failed",
    "phase" : "query",
    "grouped" : true,
    "failed_shards" : [
      {
        "shard" : 0,
        "index" : "test1",
        "node" : "FAu7pbAtQti7e9aRaX4-bg",
        "reason" : {
          "type" : "query_shard_exception",
          "reason" : "field [geometry] is not a geo_point field",
          "index_uuid" : "e7-HPZmUR4Wpu96W6K_YXw",
          "index" : "test1"
        }
      }
    ]
  },
  "status" : 400
}

知道我错过了什么能够对 geo_shape 数据进行距离处理吗?

弹性搜索详情:

{
  "name" : "server-name",
  "cluster_name" : "elasticsearch",
  "cluster_uuid" : "1SqVbKmGR5qxG6bcpjxasg",
  "version" : {
    "number" : "7.10.2",
    "build_flavor" : "oss",
    "build_type" : "deb",
    "build_hash" : "747e1cc71def077253878a59143c1f785afa92b9",
    "build_date" : "2021-01-13T00:42:12.435326Z",
    "build_snapshot" : false,
    "lucene_version" : "8.7.0",
    "minimum_wire_compatibility_version" : "6.8.0",
    "minimum_index_compatibility_version" : "6.0.0-beta1"
  },
  "tagline" : "You Know, for Search"
}

【问题讨论】:

    标签: elasticsearch geospatial distance elasticsearch-geo-shape


    【解决方案1】:

    7.10 only supported geo_point fields 中的geo_distance 查询。

    geo_shapestarted in 7.11的支持

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-03-06
      • 2012-10-31
      • 1970-01-01
      • 2020-01-18
      • 1970-01-01
      • 2017-04-08
      • 1970-01-01
      相关资源
      最近更新 更多