如何在 Elasticsearch 中 return geo_shapes 的地理空间距离结果

How to return geospatial distance results for geo_shapes in Elasticsearch

我有两个索引,都有超过 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 数据计算距离吗?

elasticsearch 详细信息:

{
  "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"
}

7.10only supported geo_point fields中的geo_distance查询

支持 geo_shape started in 7.11