awaitTaskCompleted

suspend fun SearchClient.awaitTaskCompleted(id: TaskId, timeout: Duration, interval: Duration = 5.seconds): JsonObject?
suspend fun SearchClient.awaitTaskCompleted(id: String, timeout: Duration, interval: Duration = 5.seconds): JsonObject?

Polls the given task id to check if the task is completed. Waits for timeout and polls every interval to check if the task is completed.

Returns the task response object with an embedded response for the task if completed, null if the task does not exist.

Throws an exception if the task does not complete before the timeout or if Elasticsearch returns an error.