我正在尝试使用以下行重新索引:
POST _reindex
{
"source": {
"index": "poi_201705"
},
"dest": {
"index": "poi_dev_2"
}
}
但是我在 kibana 控制台中收到以下错误:
{
"statusCode": 504,
"error": "Gateway Time-out",
"message": "Client request timeout"
}
任何人都可以告诉我这是什么问题以及如何解决它。
504 只是表示请求仍在运行,但从 Kibana 到 ES 的 HTTP 连接超时。
您仍然可以使用任务管理 API 来查看正在进行的请求,如下所示:
GET _tasks?actions=*reindex&detailed
如果您想异步运行任务,也可以使用以下命令来完成:
POST _reindex?wait_for_completion=false
这将返回一个任务 ID,然后可以通过以下方式检查其进度:
GET _tasks/<task-id>
GET _cat/indices/source_index,destination_index
API 调用结果。GET source_index,destination_index/_count
API 比较文档数量。为了防止
504 Gateway Time-out Client request timeout
错误,您可以使用?wait_for_completion=false
。
如果请求包含wait_for_completion=false,Elasticsearch 执行一些预检检查,启动请求,并返回 您可以使用任务来取消或获取任务的状态。 Elasticsearch 创建此任务的记录作为文档,位于 _任务/
。 https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-reindex.html#docs-reindex-task-api
POST _reindex?wait_for_completion=false
{
"conflicts": "proceed",
"source": {
"index": "kong-01"
},
"dest": {
"index": "kong-01-new"
}
}
回复:
{
"task": "Djf3dFpkQle-dqjG0sf6tw:45922151"
}
检查重建索引过程:
GET _tasks/Djf3dFpkQle-dqjG0sf6tw:45922151
任务 API 调用的输出示例:
{
"completed": true,
"task": {
"node": "Djf3dFpkQle-dqjG0sf6tw",
"id": 45932237,
"type": "transport",
"action": "indices:data/write/reindex",
"status": {
"total": 156,
"updated": 48,
"created": 92,
"deleted": 0,
"batches": 1,
"version_conflicts": 0,
"noops": 0,
"retries": {
"bulk": 0,
"search": 0
},
"throttled_millis": 0,
"requests_per_second": -1,
"throttled_until_millis": 0
},
"description": "reindex from [kong-01] to [kong-01-new]",
"start_time_in_millis": 1706771247512,
"running_time_in_nanos": 4811870265,
"cancellable": true,
"cancelled": false,
"headers": {
"trace.id": "abb652b45138f6becbc163bb918df48d"
}
},
"response": {
"took": 4794,
"timed_out": false,
"total": 156,
"updated": 48,
"created": 92,
"deleted": 0,
"batches": 1,
"version_conflicts": 0,
"noops": 0,
"retries": {
"bulk": 0,
"search": 0
},
"throttled": "0s",
"throttled_millis": 0,
"requests_per_second": -1,
"throttled_until": "0s",
"throttled_until_millis": 0,
"failures": [ ]
}
}