Skip to content

Commit

Permalink
✨ Add wait for completion to reindex API
Browse files Browse the repository at this point in the history
  • Loading branch information
Quentin committed Apr 19, 2023
1 parent 3f76473 commit 9d147bf
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/Provider/IndexProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,14 @@ public function rebuildIndex($markAsLive = true, $removeOldIndexes = true): Inde
/**
* Update fields mapping
*/
public function rebuildMapping(): Index
public function rebuildMapping(bool $waitForCompletion = true): Index
{
$realName = sprintf('%s_rebuild_mapping_%s', $this->name, date('YmdHis'));
$index = $this->getIndexByName($realName);
$index->create($this->config);

$this->client->request('_reindex?slices='.$this->sliceThreadNumber, Request::POST,[
$strWaitForCompletion = $waitForCompletion ? 'true' : 'false';
$this->client->request("_reindex?wait_for_completion=$strWaitForCompletion&slices=$this->sliceThreadNumber", Request::POST,[
'source' => [
'index' => $this->name,
],
Expand Down

0 comments on commit 9d147bf

Please sign in to comment.