Skip to content

Commit 20df7a5

Browse files
committed
reindex method upgrade
1 parent 4f83a65 commit 20df7a5

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/Connection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ public function __call($method, $parameters)
204204
$this->index = $this->indexPrefix.'*';
205205
}
206206

207-
$bridge = new Bridge($this->client, $this->index, $this->maxSize);
207+
$bridge = new Bridge($this->client, $this->index, $this->maxSize, $this->indexPrefix);
208208

209209
return $bridge->{'process'.Str::studly($method)}(...$parameters);
210210
}

src/DSL/Bridge.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,15 @@ class Bridge
2424

2525
private $index;
2626

27+
private $indexPrefix;
2728

28-
public function __construct(Client $client, $index, $maxSize)
29+
30+
public function __construct(Client $client, $index, $maxSize, $indexPrefix = null)
2931
{
3032
$this->client = $client;
3133
$this->index = $index;
3234
$this->maxSize = $maxSize;
35+
$this->indexPrefix = $indexPrefix;
3336

3437
if (!empty(config('database.connections.elasticsearch.logging.index'))) {
3538
$this->queryLogger = config('database.connections.elasticsearch.logging.index');
@@ -490,7 +493,7 @@ public function processIndexModify($settings)
490493
*/
491494
public function processReIndex($oldIndex, $newIndex)
492495
{
493-
$prefix = str_replace('*', '', $this->index);
496+
$prefix = $this->indexPrefix;
494497
if ($prefix) {
495498
$oldIndex = $prefix.'_'.$oldIndex;
496499
$newIndex = $prefix.'_'.$newIndex;

0 commit comments

Comments
 (0)