Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not wait for Elasticsearch reindex to finish #165

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/IndexBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You might also call $reindex->setWaitForCompletion() as well.

This may push some additional change in this method. The setWaitForCompletion() could always receive false, then this method performs what it needs based on the $waitForCompletion. Or we also could call setWaitForCompletion() passing $waitForCompletion value and let the lib do the "wait" for us.

return $newIndex;
}

$taskId = $response->getData()['task'];

$task = new Task($this->client, $taskId);
Expand Down