@@ -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 ' ,
@@ -131,52 +140,23 @@ protected function execute(InputInterface $input, OutputInterface $output): int
131140
132141 if ($ classDefinitionId ) {
133142 $ updateAll = false ;
134-
135- try {
136- $ classDefinition = ClassDefinition::getById ($ classDefinitionId );
137- if (!$ classDefinition ) {
138- throw new IdNotFoundException (
139- sprintf ('ClassDefinition with id %s not found ' , $ classDefinitionId )
140- );
141- }
142-
143- $ this ->output ->writeln (
144- sprintf (
145- '<info>Update index and indices for ClassDefinition with id %s</info> ' ,
146- $ classDefinitionId
147- ),
148- OutputInterface::VERBOSITY_NORMAL
149- );
150-
151- $ this
152- ->indexUpdateService
153- ->updateClassDefinition ($ classDefinition );
154- } catch (Exception $ e ) {
155- $ this ->output ->writeln ('<error> ' . $ e ->getMessage () . '</error> ' );
156- }
143+ $ this ->updateClassDefinition ($ classDefinitionId );
157144 }
158145
159146 if ($ input ->getOption (self ::OPTION_UPDATE_ASSET_INDEX )) {
160147 $ updateAll = false ;
148+ $ this ->updateAssets ();
149+ }
161150
162- try {
163- $ output ->writeln (
164- '<info>Update asset index</info> ' ,
165- OutputInterface::VERBOSITY_NORMAL
166- );
167-
168- $ this
169- ->indexUpdateService
170- ->updateAssets ();
171- } catch (Exception $ e ) {
172- $ this ->output ->writeln ($ e ->getMessage ());
173- }
151+ if ($ input ->getOption (self ::OPTION_UPDATE_DOCUMENT_INDEX )) {
152+ $ updateAll = false ;
153+ $ this ->updateDocuments ();
174154 }
175155
176156 if ($ updateAll ) {
177157 try {
178158 $ this ->output ->writeln (
179- '<info>Update all mappings and indices for objects/assets</info> ' ,
159+ '<info>Update all mappings and indices for objects/assets/documents </info> ' ,
180160 OutputInterface::VERBOSITY_NORMAL
181161 );
182162
@@ -203,6 +183,62 @@ protected function execute(InputInterface $input, OutputInterface $output): int
203183 return self ::SUCCESS ;
204184 }
205185
186+ private function updateClassDefinition (string $ classDefinitionId ): void
187+ {
188+ try {
189+ $ classDefinition = ClassDefinition::getById ($ classDefinitionId );
190+ if (!$ classDefinition ) {
191+ throw new IdNotFoundException (
192+ sprintf ('ClassDefinition with id %s not found ' , $ classDefinitionId )
193+ );
194+ }
195+
196+ $ this ->output ->writeln (
197+ sprintf (
198+ '<info>Update index and indices for ClassDefinition with id %s</info> ' ,
199+ $ classDefinitionId
200+ ),
201+ OutputInterface::VERBOSITY_NORMAL
202+ );
203+
204+ $ this
205+ ->indexUpdateService
206+ ->updateClassDefinition ($ classDefinition );
207+ } catch (Exception $ e ) {
208+ $ this ->output ->writeln ('<error> ' . $ e ->getMessage () . '</error> ' );
209+ }
210+ }
211+
212+ private function updateAssets () : void {
213+ try {
214+ $ this ->output ->writeln (
215+ '<info>Update asset index</info> ' ,
216+ OutputInterface::VERBOSITY_NORMAL
217+ );
218+
219+ $ this
220+ ->indexUpdateService
221+ ->updateAssets ();
222+ } catch (Exception $ e ) {
223+ $ this ->output ->writeln ($ e ->getMessage ());
224+ }
225+ }
226+
227+ private function updateDocuments () : void {
228+ try {
229+ $ this ->output ->writeln (
230+ '<info>Update document index</info> ' ,
231+ OutputInterface::VERBOSITY_NORMAL
232+ );
233+
234+ $ this
235+ ->indexUpdateService
236+ ->updateDocuments ();
237+ } catch (Exception $ e ) {
238+ $ this ->output ->writeln ($ e ->getMessage ());
239+ }
240+ }
241+
206242 private function updateGlobalIndexAliases (): void
207243 {
208244 $ this ->output ->writeln (
0 commit comments