Ejemplo n.º 1
0
 /**
  * Delete Solr index and loop over every NodesSources to index them again.
  *
  * @param \Solarium\Client $this->solr
  * @param OutputInterface  $output
  */
 private function reindexNodeSources(\Solarium\Client $solr, OutputInterface $output)
 {
     $update = $this->solr->createUpdate();
     // Empty first
     $update->addDeleteQuery('*:*');
     $this->solr->update($update);
     $update->addCommit();
     /*
      * Use buffered insertion
      */
     $buffer = $this->solr->getPlugin('bufferedadd');
     $buffer->setBufferSize(100);
     // Then index
     $nSources = $this->entityManager->getRepository('RZ\\Roadiz\\Core\\Entities\\NodesSources')->findAll();
     $progress = new ProgressBar($output, count($nSources));
     $progress->setFormat('verbose');
     $progress->start();
     foreach ($nSources as $ns) {
         $solariumNS = new SolariumNodeSource($ns, $this->solr);
         $solariumNS->setDocument($update->createDocument());
         $solariumNS->index();
         $buffer->addDocument($solariumNS->getDocument());
         $progress->advance();
     }
     $buffer->flush();
     // optimize the index
     $update->addOptimize(true, false, 5);
     $progress->finish();
 }