Skip to content

Commit 3b87744

Browse files
committed
reindex method upgrade
1 parent 82af550 commit 3b87744

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-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: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,14 @@ class Bridge
2424

2525
private string|null $index;
2626

27+
private string|null $indexPrefix;
2728

28-
public function __construct(Client $client, $index, $maxSize)
29+
public function __construct(Client $client, $index, $maxSize, $indexPrefix = null)
2930
{
3031
$this->client = $client;
3132
$this->index = $index;
3233
$this->maxSize = $maxSize;
34+
$this->indexPrefix = $indexPrefix;
3335

3436
if (!empty(config('database.connections.elasticsearch.logging.index'))) {
3537
$this->queryLogger = config('database.connections.elasticsearch.logging.index');
@@ -488,7 +490,7 @@ public function processIndexModify($settings): bool
488490
*/
489491
public function processReIndex($oldIndex, $newIndex): Results
490492
{
491-
$prefix = str_replace('*', '', $this->index);
493+
$prefix = $this->indexPrefix;
492494
if ($prefix) {
493495
$oldIndex = $prefix.'_'.$oldIndex;
494496
$newIndex = $prefix.'_'.$newIndex;

0 commit comments

Comments
 (0)