如何使用 reindex API 重命名索引

How to rename index with reindex API

我正在尝试重命名 Elasticsearch 上的索引,并且按照 的已接受解决方案中的建议,我正在使用 Reindex API。我正在使用以下命令:

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

但是我收到了这个输出:

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

我试过在重新索引之前创建索引,但没有创建它,每次我都得到相同的输出。知道为什么吗?提前致谢。

编辑: 我刚刚再次测试它,它发生了一些奇怪的事情。正在重新索引索引,但仍显示错误消息。对此有什么解释吗?该消息令人困惑,因为它似乎失败了,但它应该 运行 仍然...

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...

这是因为socket读取超时,可以读取more here

默认情况下,读取在 30 秒后超时,而重新索引仍在进行中。您可以增加超时以避免此错误。

另外,即使超时,也可以使用下面command to check current progress

GET _tasks?detailed=true&actions=*reindex