Skip to content

Commit 95b344c

Browse files
committed
delete orphaned non b/g indices when b/g is requested
1 parent b2a6aea commit 95b344c

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

src/Jobs/SetupIndex.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,13 @@ public function handle(ElasticaClient $elastica): void
2525
return;
2626
}
2727

28+
if ($this->deleteExisting && $this->indexConfig->hasBlueGreenIndices()) {
29+
$index = $elastica->getClient()->getIndex($this->indexConfig->getName());
30+
if (count($index->getAliases()) === 0) {
31+
$index->delete();
32+
}
33+
}
34+
2835
foreach (IndexInterface::INDEX_SUFFIXES as $suffix) {
2936
$name = $this->indexConfig->getName().$suffix;
3037
$aliasIndex = $elastica->getIndex($name);

src/LaravelElasticaBridgeServiceProvider.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
namespace Limenet\LaravelElasticaBridge;
66

77
use Illuminate\Database\Eloquent\Model;
8+
89
use function Illuminate\Events\queueable;
10+
911
use Illuminate\Support\Facades\Event;
1012
use Limenet\LaravelElasticaBridge\Client\ElasticaClient;
1113
use Limenet\LaravelElasticaBridge\Commands\IndexCommand;

0 commit comments

Comments
 (0)