elasticsearch - 我可以在Elasticsearch 7.x中从get geo_point存储geo_shape吗?

标签 elasticsearch geolocation geometry kibana geospatial

我的ES 7.x系统实时存储geo_point数据。
喜欢 :

{
"id" : "john",
"age" : 26,
"geo" : "57.233, 129.11"
"address" : "Rovert Hall"
}

我想自动实时获取存储的geo_shape数据,从而自动存储geo_point数据。

然后,使用id查询并获取make的geo_shape数据。我怎样才能做到呢?
如果这是不可能的,我想得到任何类似的建议。

最佳答案

实现此目的的一种方法是利用script摄取处理器并动态创建geo_shape(Point类型)。

首先创建管道:

PUT _ingest/pipeline/point-to-shape
{
    "processors": [
      {
        "script": {
          "source": """
           def latLon = /,/.split(ctx.geo);
           ctx.shape = [
             "type" : "point",
             "coordinates" : [latLon[1], latLon[0]]
           ];
          """
        }
      }
    ]
}

然后,我们为您的文档建立索引,只需引用该管道即可,如下所示:
PUT index/_doc/1?pipeline?point-to-shape
{
  "id" : "john",
  "age" : 26,
  "geo" : "57.233, 129.11",
  "address" : "Rovert Hall"
}

然后生成的文档将是:
     {
      "geo" : "57.233, 129.11",
      "address" : "Rovert Hall",
      "shape" : {
        "coordinates" : [
          " 129.11",
          "57.233"
        ],
        "type" : "point"
      },
      "id" : "john",
      "age" : 26
    }

PS:您还需要确保索引的shape字段具有正确的geo_shape映射类型。

关于elasticsearch - 我可以在Elasticsearch 7.x中从get geo_point存储geo_shape吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58872224/

相关文章:

elasticsearch - 具有多个字段值 (bank_name) 的字段 (userid) 的 Kibana 聚合可视化

elasticsearch - 如何搜索没有特定字段的文档/记录?

elasticsearch - 在Elasticsearch中增强查询

python - 使用 Python 请求查询 ElasticSearch 无法正常工作

android - 通话或短信电话位置

c++ - 是什么让 Qt 小部件及其布局正确运行(就其大小而言)?

c++ - 使用 Direct2D 组合多个几何图形

ios - 地理定位在 iOS 8 模拟器中不起作用

javascript - 如何将map.locate与Polymer 1.0/leaflet-map 1.0一起使用

algorithm - Language Agonostic - 获取矩形内的所有坐标