Search code examples
elasticsearchreindex

Timeout Response for Failed Elasticsearch Re-index


I'm using re-index api of Elasticsearch to move documents from an index (named index1) to another index (named index2).

My problem rises when the size of index1 is too big, so the time out response comes back from Elasticsearch. There is another query (GET _tasks?detailed=true&actions=*reindex) which shows the reindex procedure. But I can't figure out how I can see the errors if there are errors during the reindex time and why my reindex task fails.

One possible solution that I don't like is to increase the time out response of Elasticsearch. Is there any solution that I can see the errors without increasing the time out?


Solution

  • What I usually do is to launch the reindex with ?wait_for_completion=false, so that a background task gets created. The reindex call will return almost immediately and tell you the ID of the task that was created.

    You can then use the Task API to check the status of the task using:

    GET .tasks/task/<taskId>
    

    Even when the reindex is done, the task will stay in the index and you can check the errors if any.

    It is your responsibility, though, to delete that document using:

    DELETE .tasks/task/<taskId>