From 3e5a67b6fea5ff316b6cfb2fd0ba37a62bb69ab5 Mon Sep 17 00:00:00 2001 From: Linus Metzler Date: Thu, 25 Jan 2024 14:15:30 +0100 Subject: [PATCH] improve cleanup & status commands --- src/Command/Cleanup.php | 9 +++++++++ src/Command/NonBundleIndexTrait.php | 13 +++++++++++++ src/Command/Status.php | 3 ++- 3 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 src/Command/NonBundleIndexTrait.php diff --git a/src/Command/Cleanup.php b/src/Command/Cleanup.php index 4486739..819ca50 100644 --- a/src/Command/Cleanup.php +++ b/src/Command/Cleanup.php @@ -15,6 +15,7 @@ class Cleanup extends BaseCommand { + use NonBundleIndexTrait; private const OPTION_ALL_IN_CLUSTER = 'all'; public function __construct( @@ -54,8 +55,16 @@ protected function execute(InputInterface $input, OutputInterface $output): int $indices = $this->getIndices(); foreach ($indices as $index) { + if (!$this->shouldProcessNonBundleIndex($index)) { + continue; + } + $client = $this->esClient->getIndex($index); + if ($client->getSettings()->getBool('hidden')) { + continue; + } + foreach ($client->getAliases() as $alias) { $client->removeAlias($alias); } diff --git a/src/Command/NonBundleIndexTrait.php b/src/Command/NonBundleIndexTrait.php new file mode 100644 index 0000000..47f94f4 --- /dev/null +++ b/src/Command/NonBundleIndexTrait.php @@ -0,0 +1,13 @@ +> */ @@ -67,7 +68,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $table->render(); foreach ($this->esClient->getCluster()->getIndexNames() as $indexName) { - if (in_array($indexName, $this->skipOtherIndices, true)) { + if (in_array($indexName, $this->skipOtherIndices, true) || !$this->shouldProcessNonBundleIndex($indexName)) { continue; } $this->processOtherIndex($indexName);