Skip to content

Commit

Permalink
Simplify code
Browse files Browse the repository at this point in the history
  • Loading branch information
markus-moser committed Jan 15, 2024
1 parent b2e0293 commit 88904db
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/Service/SearchIndex/OpenSearch/OpenSearchService.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,14 @@ public function getCurrentIndexVersion(string $indexName): string
public function reindex(string $indexName, array $mapping): void
{
$currentIndexVersion = $this->getCurrentIndexVersion($indexName);
$newIndexVersion = $currentIndexVersion === self::INDEX_VERION_EVEN
? self::INDEX_VERION_ODD
: self::INDEX_VERION_EVEN;

$oldIndexName = $indexName . '-' . $currentIndexVersion;
$newIndexName = $indexName . '-' . ($currentIndexVersion === self::INDEX_VERION_EVEN ? self::INDEX_VERION_ODD : self::INDEX_VERION_EVEN);
$this->createIndex($indexName . '-' . ($currentIndexVersion === self::INDEX_VERION_EVEN ? self::INDEX_VERION_EVEN : self::INDEX_VERION_EVEN), $mapping);
$newIndexName = $indexName . '-' . $newIndexVersion;

$this->createIndex($newIndexName, $mapping);

$body = [
'source' => [
Expand Down

0 comments on commit 88904db

Please sign in to comment.