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();
        }
    }