Skip to content

Commit 28a7242

Browse files
committed
reindex method upgrade
1 parent f287ef1 commit 28a7242

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
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: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,25 @@ class Bridge
1414

1515
use QueryBuilder, IndexInterpreter;
1616

17-
protected Client $client;
17+
protected $client;
1818

19-
protected mixed $queryLogger = false;
19+
protected $queryLogger = false;
2020

21-
protected mixed $queryLoggerOnErrorOnly = true;
21+
protected $queryLoggerOnErrorOnly = true;
2222

23-
protected int|null $maxSize = 10; //ES default
23+
protected $maxSize = 10; //ES default
2424

25-
private string|null $index;
25+
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');
@@ -488,7 +491,7 @@ public function processIndexModify($settings): bool
488491
*/
489492
public function processReIndex($oldIndex, $newIndex): Results
490493
{
491-
$prefix = str_replace('*', '', $this->index);
494+
$prefix = $this->indexPrefix;
492495
if ($prefix) {
493496
$oldIndex = $prefix.'_'.$oldIndex;
494497
$newIndex = $prefix.'_'.$newIndex;

0 commit comments

Comments
 (0)