Search code examples
elasticsearchreindex

How to rename index with reindex API


I'm trying to rename an index on Elasticsearch and as suggested in the accepted solution of this question I'm using the Reindex API. I'm using the following command:

POST _reindex
{
  "source": {
    "index": "original-index"
  },
  "dest": {
    "index": "new-index"
  }
}

But I'm receiving this output:

{
  "ok": false,
  "message": "Unable to connect to the server."
}

I have tried creating the index before doing the reindex and without having it created and every time I get the same output. Any idea why? Thanks in advance.

EDIT: I have just tested it again and it happens something strange. The index is being reindexed, but the error message is still being displayed. Any explanation about that? The message is confusing cause it seems to have failed, but it should be running still...


Solution

  • EDIT: I have just tested it again and it happens something strange. The index is being reindexed, but the error message is still being displayed. Any explanation about that? The message is confusing cause it seems to have failed, but it should be running still...

    This is because of the socket read timeout, you can read more here

    By default, the read times out in 30s while the re-indexing is still in progress. You can increase the timeout to avoid this error.

    Also, even if it times out, you can use below command to check current progress

    GET _tasks?detailed=true&actions=*reindex