diff --git a/src/Jobs/SetupIndex.php b/src/Jobs/SetupIndex.php index 1703b2b..6900872 100644 --- a/src/Jobs/SetupIndex.php +++ b/src/Jobs/SetupIndex.php @@ -43,7 +43,7 @@ private function migrate(ElasticaClient $elastica): void try { $response = $elastica->getClient()->request(sprintf('_alias/%s', $this->indexConfig->getName())); } catch (ClientException|ConnectionException|ResponseException) { - if (count($index->getAliases()) === 0) { + if ($index->exists() && count($index->getAliases()) === 0) { $index->delete(); } @@ -58,7 +58,9 @@ private function migrate(ElasticaClient $elastica): void return; } - $index->delete(); + if ($index->exists()) { + $index->delete(); + } } private function cleanup(ElasticaClient $elastica): void