fblundun
fblundun

Reputation: 1017

How do I wait for Elasticsearch to finish cloning an index?

I'm doing Elasticsearch reindexing as a multistep process using the JavaScript client library:

I need to wait for the 1st step to complete before doing the next steps. Is there an Elasticsearch endpoint I can poll to find out when the clone is complete?

Upvotes: 1

Views: 38

Answers (2)

Paulo
Paulo

Reputation: 10746

Tldr;

If I recall correctly, there is no specific endpoint for monitoring the clone API. But you can use the cat recovery api

Demo

POST old/_clone/new

# This call is to be made until it returns nothing
GET _cat/recovery/new?active_only=true&format=json

DELETE old

Upvotes: 1

Musab Dogan
Musab Dogan

Reputation: 3680

You can use the wait_for_completion parameter to get a task_id and track the process with _tasks API call it.

POST _reindex?wait_for_completion=false
{
  "conflicts": "proceed", 
  "source": {
    "index": "old"
  },
  "dest": {
    "index": "new"
  }
}

GET _tasks/Z5nYSIXKRG2S5buc5-4L4A:536203711

A useful article: https://www.elastic.co/blog/3-best-practices-for-using-and-troubleshooting-the-reindex-api

wait for completition

Upvotes: 1

Related Questions