Skip to content

Commit cce518c

Browse files
committed
reindex method upgrade
1 parent be29eba commit cce518c

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 string|null $index;
2626

27+
private string|null $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');
@@ -487,7 +490,7 @@ public function processIndexModify($settings): bool
487490
*/
488491
public function processReIndex($oldIndex, $newIndex): Results
489492
{
490-
$prefix = str_replace('*', '', $this->index);
493+
$prefix = $this->indexPrefix;
491494
if ($prefix) {
492495
$oldIndex = $prefix.'_'.$oldIndex;
493496
$newIndex = $prefix.'_'.$newIndex;

0 commit comments

Comments
 (0)