Skip to content

Commit

Permalink
Merge pull request #24 from qporion/feature--add-wait-for-completion-…
Browse files Browse the repository at this point in the history
…reindex-api

✨ Add wait for completion to reindex API
  • Loading branch information
CheapHasz authored Apr 19, 2023
2 parents 3f76473 + 9d147bf commit 23db09a
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 23db09a

Please sign in to comment.