We're using reindex from remote in order to pull indices from a 1.7.2 cluster to a 5.1.2 cluster. We combined the guidance on how to use painless for this scenario and the reindex from remote option from this article: https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-reindex.html to generate the script below. It works; it does exactly what the documentation says it will do: All the new indices are named what they were in the source cluster, except there is a "-1" appended. Thing is, we don't want the name changed at all. How do we do that?
Here is what we tried first (it's our application of the example in the article above)
"inline": "ctx.index = 'onlineusers' + (ctx.index.substring('onlineusers'.length(), ctx._index.length()))+ '-1'"
We messed around a bit with the ctx script to try to get it to not append anything. For example, we tried:
"inline": "ctx.index = 'onlineusers' + (ctx.index.substring('onlineusers'.length(), ctx._index.length()))"
but when we do that, it just puts all the documents from the daily indices into one index named onlineusers)_.
Worst case scenario, I can use the script as provided, that appends the -1, then reindex again locally with this:
"inline": "ctx.index = 'twittervolumeitems' + (ctx.index.substring('twittervolumeitems'.length(), ctx._index.length()-2))"
to remove the "-1" from the end. Tested that and it works, but it's double the work, and it seems we should be able to use the initial script to maintain the same index name.