protected function indexDocuments($locale, IndexerInterface $indexer, OutputInterface $output)
    {
        $documents = $this->getDocuments($locale);
        $count = count($documents);
        if (0 === $count) {
            $output->writeln('  No documents found');

            return;
        }

        $progessBar = new ProgressBar($output, $count);
        $progessBar->setFormat(' %current%/%max% [%bar%] %percent:3s%% %elapsed:6s%/%estimated:-6s% %memory:6s%');
        $progessBar->start();

        foreach ($documents as $document) {
            $indexer->index($document);
            $progessBar->advance();
        }

        $indexer->flush();
        $progessBar->finish();
    }