Classes/Command/NodeIndexCommandController.php
public function buildCommand(int $limit = null, bool $update = false, string $workspace = null, string $postfix = ''): void
    {
        if ($workspace !== null && $this->workspaceRepository->findByIdentifier($workspace) === null) {
            $this->logger->log('The given workspace (' . $workspace . ') does not exist.', LOG_ERR);
            $this->quit(1);
        }

        if ($update === true) {
            $this->logger->log('!!! Update Mode (Development) active!');
        } else {
            $this->createNewIndex($postfix);
        }
        $this->applyMapping();

        $this->logger->log(sprintf('Indexing %snodes ... ', ($limit !== null ? 'the first ' . $limit . ' ' : '')));

        $count = 0;

        if ($workspace === null && $this->settings['indexAllWorkspaces'] === false) {
            $workspace = 'live';
        }

        $callback = function ($workspaceName, $indexedNodes, $dimensions) {
            if ($dimensions === []) {
                $this->outputLine('Workspace "' . $workspaceName . '" without dimensions done. (Indexed ' . $indexedNodes . ' nodes)');
            } else {
                $this->outputLine('Workspace "' . $workspaceName . '" and dimensions "' . json_encode($dimensions) . '" done. (Indexed ' . $indexedNodes . ' nodes)');
            }
        };
        if ($workspace === null) {
            foreach ($this->workspaceRepository->findAll() as $workspaceToIndex) {
                $count += $this->indexWorkspace($workspaceToIndex->getName(), $limit, $callback);
            }
        } else {
            $count += $this->indexWorkspace($workspace, $limit, $callback);
        }

        $this->nodeIndexingManager->flushQueues();

        if ($this->errorHandlingService->hasError()) {
            $this->outputLine();
            /** @var ErrorInterface $error */
            foreach ($this->errorHandlingService as $error) {
                $this->outputLine('<error>Error</error> ' . $error->message());
            }
            $this->outputLine();
            $this->outputLine('<error>Check your logs for more information</error>');
        } else {
            $this->logger->log('Done. (indexed ' . $count . ' nodes)', LOG_INFO);
        }
        $this->nodeIndexer->getIndex()->refresh();

        // TODO: smoke tests
        if ($update === false) {
            $this->nodeIndexer->updateIndexAlias();
        }
    }
public function buildCommand(int $limit = null, bool $update = false, string $workspace = null, string $postfix = ''): void
    {
        if ($workspace !== null && $this->workspaceRepository->findByIdentifier($workspace) === null) {
            $this->logger->log('The given workspace (' . $workspace . ') does not exist.', LOG_ERR);
            $this->quit(1);
        }

        if ($update === true) {
            $this->logger->log('!!! Update Mode (Development) active!');
        } else {
            $this->createNewIndex($postfix);
        }
        $this->applyMapping();

        $this->logger->log(sprintf('Indexing %snodes ... ', ($limit !== null ? 'the first ' . $limit . ' ' : '')));

        $count = 0;

        if ($workspace === null && $this->settings['indexAllWorkspaces'] === false) {
            $workspace = 'live';
        }

        $callback = function ($workspaceName, $indexedNodes, $dimensions) {
            if ($dimensions === []) {
                $this->outputLine('Workspace "' . $workspaceName . '" without dimensions done. (Indexed ' . $indexedNodes . ' nodes)');
            } else {
                $this->outputLine('Workspace "' . $workspaceName . '" and dimensions "' . json_encode($dimensions) . '" done. (Indexed ' . $indexedNodes . ' nodes)');
            }
        };
        if ($workspace === null) {
            foreach ($this->workspaceRepository->findAll() as $workspaceToIndex) {
                $count += $this->indexWorkspace($workspaceToIndex->getName(), $limit, $callback);
            }
        } else {
            $count += $this->indexWorkspace($workspace, $limit, $callback);
        }

        $this->nodeIndexingManager->flushQueues();

        if ($this->errorHandlingService->hasError()) {
            $this->outputLine();
            /** @var ErrorInterface $error */
            foreach ($this->errorHandlingService as $error) {
                $this->outputLine('<error>Error</error> ' . $error->message());
            }
            $this->outputLine();
            $this->outputLine('<error>Check your logs for more information</error>');
        } else {
            $this->logger->log('Done. (indexed ' . $count . ' nodes)', LOG_INFO);
        }
        $this->nodeIndexer->getIndex()->refresh();

        // TODO: smoke tests
        if ($update === false) {
            $this->nodeIndexer->updateIndexAlias();
        }
    }
public function buildCommand ( int $ limit = null , bool $ update = false , string $ workspace = null , string $ postfix = '' ) : void { if ( $ workspace !== null && $ this -> workspaceRepository -> findByIdentifier ( $ workspace ) === null ) { $ this -> logger -> log ( 'The given workspace (' . $ workspace . ') does not exist.' , LOG_ERR ) ; $ this -> quit ( 1 ) ; } if ( $ update === true ) { $ this -> logger -> log ( '!!! Update Mode (Development) active!' ) ; } else { $ this -> createNewIndex ( $ postfix ) ; } $ this -> applyMapping ( ) ; $ this -> logger -> log ( sprintf ( 'Indexing %snodes ... ' , ( $ limit !== null ? 'the first ' . $ limit . ' ' : '' ) ) ) ; $ count = 0 ; if ( $ workspace === null && $ this -> settings [ 'indexAllWorkspaces' ] === false ) { $ workspace = 'live' ; } $ callback = function ( $ workspaceName , $ indexedNodes , $ dimensions ) { if ( $ dimensions === [ ] ) { $ this -> outputLine ( 'Workspace "' . $ workspaceName . '" without dimensions done. (Indexed ' . $ indexedNodes . ' nodes)' ) ; } else { $ this -> outputLine ( 'Workspace "' . $ workspaceName . '" and dimensions "' . json_encode ( $ dimensions ) . '" done. (Indexed ' . $ indexedNodes . ' nodes)' ) ; } } ; if ( $ workspace === null ) { foreach ( $ this -> workspaceRepository -> findAll ( ) as $ workspaceToIndex ) { $ count += $ this -> indexWorkspace ( $ workspaceToIndex -> getName ( ) , $ limit , $ callback ) ; } } else { $ count += $ this -> indexWorkspace ( $ workspace , $ limit , $ callback ) ; } $ this -> nodeIndexingManager -> flushQueues ( ) ; if ( $ this -> errorHandlingService -> hasError ( ) ) { $ this -> outputLine ( ) ; /** @var ErrorInterface $error */ foreach ( $ this -> errorHandlingService as $ error ) { $ this -> outputLine ( '<error>Error</error> ' . $ error -> message ( ) ) ; } $ this -> outputLine ( ) ; $ this -> outputLine ( '<error>Check your logs for more information</error>' ) ; } else { $ this -> logger -> log ( 'Done. (indexed ' . $ count . ' nodes)' , LOG_INFO ) ; } $ this -> nodeIndexer -> getIndex ( ) -> refresh ( ) ; // TODO: smoke tests if ( $ update === false ) { $ this -> nodeIndexer -> updateIndexAlias ( ) ; } }
Index all nodes by creating a new index and when everything was completed, switch the index alias.

This command (re-)indexes all nodes contained in the content repository and sets the schema beforehand.

@param int $limit Amount of nodes to index at maximum
@param bool $update if TRUE, do not throw away the index at the start. Should *only be used for development*.
@param string $workspace name of the workspace which should be indexed
@param string $postfix Index postfix, index with the same postfix will be deleted if exist
@return void
@throws ApiException
@throws StopActionException
@throws CRAException
Index all nodes by creating a new index and when everything was completed switch the index alias .