From 34e3a258950cbcdb8f71d31f4fa58b5007f7710a Mon Sep 17 00:00:00 2001 From: Baptiste Leduc Date: Tue, 16 May 2023 16:33:02 +0200 Subject: [PATCH 1/2] Update IndexBuilder.php --- src/IndexBuilder.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/IndexBuilder.php b/src/IndexBuilder.php index 398324e..438914d 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); From 763637b8f61d074a678bbc24ca3d26ea36a3a7f6 Mon Sep 17 00:00:00 2001 From: Baptiste Leduc Date: Tue, 16 May 2023 16:35:41 +0200 Subject: [PATCH 2/2] cs-fix --- src/IndexBuilder.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/IndexBuilder.php b/src/IndexBuilder.php index 438914d..ae98407 100644 --- a/src/IndexBuilder.php +++ b/src/IndexBuilder.php @@ -87,7 +87,7 @@ public function migrate(Index $currentIndex, array $params = [], array $context if (!$waitForCompletion) { return $newIndex; } - + $taskId = $response->getData()['task']; $task = new Task($this->client, $taskId);