0

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?

Val
  • 207,596
  • 13
  • 358
  • 360
Trind
  • 1,583
  • 4
  • 18
  • 38

1 Answers1

0

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"
  }
}
Val
  • 207,596
  • 13
  • 358
  • 360
  • Sorry, wern't at work today, will try it first time tomorrow. i think however i have tried something like this, is ctx the new object or the old one from the remote source? – Trind Mar 29 '17 at 18:42
  • Dosn't work, the timestamp field ends up "timestamp": null, :/ – Trind Mar 30 '17 at 06:37
  • Did you find a solution? – user2689782 Jun 02 '17 at 15:55
  • Yes, see this other question and my answer: https://stackoverflow.com/questions/44379396/elasticsearch-1-x-add-field-copy-of-timestamp the idea is to first copy the `_timestamp` field in your 1.4 index as a regular field and then this problem won't exist anymore. – Val Jun 06 '17 at 05:49