Reindex data from Elasticsearch 1.X to ElastichSearch with old _timeStamp to new Field

匆匆过客 提交于 2019-12-13 07:27:18

问题


I am trying to migrate my data from an old Elasticsearch(Version 1.4.4) Cluster to a new one (5.1)

I am using the reindex api in the new Elasticsearch, but can't get the old _timestamp to a new field timestamp. Everything else works fine.

POST _reindex
{
  "source": {
    "remote": {
      "host": "http://oldhost:9200"
    },
    "index": "source",
    "query": {
       "match_all": {}
    }
  },
  "dest": {
    "index": "dest"
  }
}

Are there any way to add a script tag to set the new field timestamp from the old _timestamp?


回答1:


I'm not 100% certain this will work, but using the reindex API you can specify a tiny bit of script that might be able to read the old _timestamp field (although I've never tried it personally):

POST _reindex
{
  "source": {
    "remote": {
      "host": "http://oldhost:9200"
    },
    "index": "source"
    "query": {
       "match_all": {}
    }
  },
  "dest": {
    "index": "dest"
  },
  "script": {
    "lang": "painless",
    "inline": "ctx._source.timestamp = ctx._timestamp"
  }
}


来源:https://stackoverflow.com/questions/43077970/reindex-data-from-elasticsearch-1-x-to-elastichsearch-with-old-timestamp-to-new

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!