public function execute()
    {
        $cliEnvironment = null;

        // Wrapped the CliEnvironment to avoid defining TYPO3_PATH_WEB since this
        // should only be done in the case when running it from outside TYPO3 BE
        // @see #921 and #934 on https://github.com/TYPO3-Solr
        if (TYPO3_REQUESTTYPE & TYPO3_REQUESTTYPE_CLI) {
            $cliEnvironment = GeneralUtility::makeInstance(CliEnvironment::class);
            $cliEnvironment->backup();
            $cliEnvironment->initialize($this->getWebRoot());
        }

        $site = $this->getSite();
        $indexService = $this->getInitializedIndexService($site);
        $indexService->indexItems($this->documentsToIndexLimit);

        if (TYPO3_REQUESTTYPE & TYPO3_REQUESTTYPE_CLI) {
            $cliEnvironment->restore();
        }

        $executionSucceeded = true;

        return $executionSucceeded;
    }