diff --git a/src/Command/Update/IndexUpdateCommand.php b/src/Command/Update/IndexUpdateCommand.php
index 051d075f..b77dcb94 100644
--- a/src/Command/Update/IndexUpdateCommand.php
+++ b/src/Command/Update/IndexUpdateCommand.php
@@ -38,6 +38,8 @@ final class IndexUpdateCommand extends AbstractCommand
private const OPTION_UPDATE_ASSET_INDEX = 'update-asset-index';
+ private const OPTION_UPDATE_DOCUMENT_INDEX = 'update-document-index';
+
private const OPTION_RECREATE_INDEX = 'recreate_index';
private const UPDATE_GLOBAL_ALIASES_ONLY = 'update-global-aliases-only';
@@ -84,6 +86,13 @@ protected function configure(): void
'Update mapping and data for asset index',
null
)
+ ->addOption(
+ self::OPTION_UPDATE_DOCUMENT_INDEX,
+ 'd',
+ InputOption::VALUE_NONE,
+ 'Update mapping and data for document index',
+ null
+ )
->addOption(
self::OPTION_RECREATE_INDEX,
'r',
@@ -131,52 +140,23 @@ protected function execute(InputInterface $input, OutputInterface $output): int
if ($classDefinitionId) {
$updateAll = false;
-
- try {
- $classDefinition = ClassDefinition::getById($classDefinitionId);
- if (!$classDefinition) {
- throw new IdNotFoundException(
- sprintf('ClassDefinition with id %s not found', $classDefinitionId)
- );
- }
-
- $this->output->writeln(
- sprintf(
- 'Update index and indices for ClassDefinition with id %s',
- $classDefinitionId
- ),
- OutputInterface::VERBOSITY_NORMAL
- );
-
- $this
- ->indexUpdateService
- ->updateClassDefinition($classDefinition);
- } catch (Exception $e) {
- $this->output->writeln('' . $e->getMessage() . '');
- }
+ $this->updateClassDefinition($classDefinitionId);
}
if ($input->getOption(self::OPTION_UPDATE_ASSET_INDEX)) {
$updateAll = false;
+ $this->updateAssets();
+ }
- try {
- $output->writeln(
- 'Update asset index',
- OutputInterface::VERBOSITY_NORMAL
- );
-
- $this
- ->indexUpdateService
- ->updateAssets();
- } catch (Exception $e) {
- $this->output->writeln($e->getMessage());
- }
+ if ($input->getOption(self::OPTION_UPDATE_DOCUMENT_INDEX)) {
+ $updateAll = false;
+ $this->updateDocuments();
}
if ($updateAll) {
try {
$this->output->writeln(
- 'Update all mappings and indices for objects/assets',
+ 'Update all mappings and indices for objects/assets/documents',
OutputInterface::VERBOSITY_NORMAL
);
@@ -203,6 +183,62 @@ protected function execute(InputInterface $input, OutputInterface $output): int
return self::SUCCESS;
}
+ private function updateClassDefinition(string $classDefinitionId)
+ {
+ try {
+ $classDefinition = ClassDefinition::getById($classDefinitionId);
+ if (!$classDefinition) {
+ throw new IdNotFoundException(
+ sprintf('ClassDefinition with id %s not found', $classDefinitionId)
+ );
+ }
+
+ $this->output->writeln(
+ sprintf(
+ 'Update index and indices for ClassDefinition with id %s',
+ $classDefinitionId
+ ),
+ OutputInterface::VERBOSITY_NORMAL
+ );
+
+ $this
+ ->indexUpdateService
+ ->updateClassDefinition($classDefinition);
+ } catch (Exception $e) {
+ $this->output->writeln('' . $e->getMessage() . '');
+ }
+ }
+
+ private function updateAssets() : void {
+ try {
+ $this->output->writeln(
+ 'Update asset index',
+ OutputInterface::VERBOSITY_NORMAL
+ );
+
+ $this
+ ->indexUpdateService
+ ->updateAssets();
+ } catch (Exception $e) {
+ $this->output->writeln($e->getMessage());
+ }
+ }
+
+ private function updateDocuments() : void {
+ try {
+ $this->output->writeln(
+ 'Update document index',
+ OutputInterface::VERBOSITY_NORMAL
+ );
+
+ $this
+ ->indexUpdateService
+ ->updateDocuments();
+ } catch (Exception $e) {
+ $this->output->writeln($e->getMessage());
+ }
+ }
+
private function updateGlobalIndexAliases(): void
{
$this->output->writeln(