将数据导入AWS Elasticsearch时映射geo_point数据

时间:2018-07-30 22:23:50

标签: amazon-web-services elasticsearch geolocation kibana

我使用以下教程将动态集内的一组数据导入到AWS Elasticsearch中:https://medium.com/@vladyslavhoncharenko/how-to-index-new-and-existing-amazon-dynamodb-content-with-amazon-elasticsearch-service-30c1bbc91365

我需要更改部分数据到geo_point的映射。

我尝试在使用以下命令导入数据之前创建映射:

PUT user
{
  "mappings": {
    "_doc": {
      "properties": {
        "grower_location": {
            "type": "geo_point"
        }
      }
    }
  }
}

执行此操作时,虽然没有收到错误,但数据不会导入。

如果我先导入数据,则可以搜索它,尽管grower_location:{lat:#,lon:#}对象已映射为整数,但我无法运行geo_distance。

请帮助。

1 个答案:

答案 0 :(得分:1)

我能够通过在教程中使用python脚本一次导入数据来解决此问题。

然后跑步

GET user/_mappings

将自动生成的映射复制到剪贴板,然后

DELETE user/

然后将复制的映射粘贴到新的映射并更改geo_point数据的类型。

PUT user/
{
   "mappings": {
     "user_type": {
       "properties": {
         ...
         "grower_location": {
           "type": "geo_point"
         }
         ...
       }
     }
   }
}

然后使用本教程中的python脚本重新导入数据。 一切都已导入,可以使用geo_point进行搜索!