Skip to content

Commit

Permalink
Adjust handling for locale index
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthias Richter committed Dec 4, 2024
1 parent bd3ab8e commit bea92d4
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions Classes/Command/IndexCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ protected function fullSync(InputInterface $input): void
}
}
$this->io->progressFinish();
$this->indexLocales();
}

protected function versionedSync(int $version): void
Expand Down Expand Up @@ -372,14 +373,27 @@ protected function commitBibliography(): void
$this->client->bulk($params);
}

/* protected function commitLocales(): void
protected function indexLocales(): void
{
$localeIndex = $this->extConf['elasticLocaleIndexName'];
$this->io->text('Committing the ' . $localeIndex . ' index');

if ($this->client->indices()->exists(['index' => $localeIndex])) {
$this->client->indices()->delete(['index' => $localeIndex]);
$this->client->indices()->create(['index' => $localeIndex]);
try {
// in older Elasticsearch versions (until 7) exists returns a bool
if ($this->client->indices()->exists(['index' => $localeIndex])) {
$this->client->indices()->delete(['index' => $localeIndex]);
$this->client->indices()->create(['index' => $localeIndex]);
}
} catch (\Exception $e) {
// other versions return a Message object
if ($e->getCode() === 404) {
$this->io->note("Index: " . $localeIndex . " does not exist. Trying to create new index.");
$this->client->indices()->create(['index' => $localeIndex]);
} else {
$this->io->error("Exception: " . $e->getMessage());
$this->logger->error('Bibliography sync unsuccessful. Error creating elasticsearch index.');
throw new \Exception('Bibliography sync unsuccessful.');
}
}

$params = [ 'body' => [] ];
Expand All @@ -396,5 +410,5 @@ protected function commitBibliography(): void
$this->client->bulk($params);

$this->io->text('done');
}*/
}
}

0 comments on commit bea92d4

Please sign in to comment.