/**
  * A command run when a population has finished.
  *
  * @param $indexName
  */
 public function postPopulate($indexName)
 {
     $indexConfig = $this->configManager->getIndexConfiguration($indexName);
     if ($indexConfig->isUseAlias()) {
         $index = $this->indexManager->getIndex($indexName);
         $this->aliasProcessor->switchIndexAlias($indexConfig, $index);
     }
 }
 /**
  * Refreshes an index.
  *
  * @param OutputInterface $output
  * @param string          $index
  * @param bool            $postPopulate
  */
 private function refreshIndex(OutputInterface $output, $index, $postPopulate = true)
 {
     if ($postPopulate) {
         $this->resetter->postPopulate($index);
     }
     $output->writeln(sprintf('<info>Refreshing</info> <comment>%s</comment>', $index));
     $this->indexManager->getIndex($index)->refresh();
 }
 /**
  * @see Symfony\Component\Console\Command\Command::execute()
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $index = $input->getOption('index');
     $type = $input->getOption('type');
     $force = (bool) $input->getOption('force');
     if (null === $index && null !== $type) {
         throw new \InvalidArgumentException('Cannot specify type option without an index.');
     }
     if (null !== $type) {
         $output->writeln(sprintf('<info>Resetting</info> <comment>%s/%s</comment>', $index, $type));
         $this->resetter->resetIndexType($index, $type);
     } else {
         $indexes = null === $index ? array_keys($this->indexManager->getAllIndexes()) : array($index);
         foreach ($indexes as $index) {
             $output->writeln(sprintf('<info>Resetting</info> <comment>%s</comment>', $index));
             $this->resetter->resetIndex($index, false, $force);
         }
     }
 }
 public function testGetDefaultIndex()
 {
     $this->assertEquals('index2', $this->indexManager->getIndex()->getName());
     $this->assertEquals('index2', $this->indexManager->getDefaultIndex()->getName());
 }