问题
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