diff --git a/src/IndexBuilder.php b/src/IndexBuilder.php index 398324e..ae98407 100644 --- a/src/IndexBuilder.php +++ b/src/IndexBuilder.php @@ -70,7 +70,7 @@ public function speedUpRefresh(Index $index): void $index->getSettings()->setRefreshInterval('1s'); } - public function migrate(Index $currentIndex, array $params = [], array $context = []): Index + public function migrate(Index $currentIndex, array $params = [], array $context = [], bool $waitForCompletion = true): Index { $pureIndexName = $this->indexNameMapper->getPureIndexName($currentIndex->getName()); $newIndex = $this->createIndex($pureIndexName, $context); @@ -84,6 +84,10 @@ public function migrate(Index $currentIndex, array $params = [], array $context throw new RuntimeException(sprintf('Reindex call failed. %s', $response->getError())); } + if (!$waitForCompletion) { + return $newIndex; + } + $taskId = $response->getData()['task']; $task = new Task($this->client, $taskId);