Skip to content

Commit 1202d6e

Browse files
authored
Add document index update option to IndexUpdateCommand
Added an option to update the document index and implemented the corresponding logic in the command.
1 parent 28d275f commit 1202d6e

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

src/Command/Update/IndexUpdateCommand.php

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ final class IndexUpdateCommand extends AbstractCommand
3838

3939
private const OPTION_UPDATE_ASSET_INDEX = 'update-asset-index';
4040

41+
private const OPTION_UPDATE_DOCUMENT_INDEX = 'update-document-index';
42+
4143
private const OPTION_RECREATE_INDEX = 'recreate_index';
4244

4345
private const UPDATE_GLOBAL_ALIASES_ONLY = 'update-global-aliases-only';
@@ -84,6 +86,13 @@ protected function configure(): void
8486
'Update mapping and data for asset index',
8587
null
8688
)
89+
->addOption(
90+
self::OPTION_UPDATE_DOCUMENT_INDEX,
91+
'd',
92+
InputOption::VALUE_NONE,
93+
'Update mapping and data for document index',
94+
null
95+
)
8796
->addOption(
8897
self::OPTION_RECREATE_INDEX,
8998
'r',
@@ -173,10 +182,27 @@ protected function execute(InputInterface $input, OutputInterface $output): int
173182
}
174183
}
175184

185+
if ($input->getOption(self::OPTION_UPDATE_DOCUMENT_INDEX)) {
186+
$updateAll = false;
187+
188+
try {
189+
$output->writeln(
190+
'<info>Update document index</info>',
191+
OutputInterface::VERBOSITY_NORMAL
192+
);
193+
194+
$this
195+
->indexUpdateService
196+
->updateDocuments();
197+
} catch (Exception $e) {
198+
$this->output->writeln($e->getMessage());
199+
}
200+
}
201+
176202
if ($updateAll) {
177203
try {
178204
$this->output->writeln(
179-
'<info>Update all mappings and indices for objects/assets</info>',
205+
'<info>Update all mappings and indices for objects/assets/documents</info>',
180206
OutputInterface::VERBOSITY_NORMAL
181207
);
182208

0 commit comments

Comments
 (0)