private function reindex(string $locale, OutputInterface $output) { $totalEntities = $this->repository->getTotalCount(); $iterations = $this->getIterations($totalEntities, $this->batchSize); $output->writeln(sprintf('<comment>Total entities:</comment> %s', $totalEntities)); $output->writeln(sprintf('<comment>Batch size:</comment> %s', $this->batchSize)); $output->writeln(sprintf('<comment>Iterations:</comment> %s', count($iterations))); $output->writeln(sprintf('<comment>Locale:</comment> %s', $locale)); $output->writeln('<info>Flushing index</info>'); $this->manager->flushIndex($locale); $progress = new ProgressBar($output, $totalEntities); $progress->setFormat('verbose'); $progress->setRedrawFrequency($this->batchSize); $progress->start(); foreach ($iterations as $iteration) { $entities = $this->getEntities($iteration); foreach ($entities as $entity) { $document = $this->type->createDocument($entity, $locale); $this->manager->addDocument($document); $progress->advance(); } } $progress->finish(); $output->writeln(''); $output->writeln('<info>Optimizing index</info>'); $this->manager->optimizeIndex($locale); }