예제 #1
0
 /**
  * @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);
         }
     }
 }
 /**
  * Deletes/remaps an index type, populates it, and refreshes the index.
  *
  * @param OutputInterface $output
  * @param string          $index
  * @param string          $type
  * @param boolean         $reset
  * @param array           $options
  */
 private function populateIndexType(OutputInterface $output, $index, $type, $reset, $options)
 {
     $event = new TypePopulateEvent($index, $type, $reset, $options);
     $this->dispatcher->dispatch(TypePopulateEvent::PRE_TYPE_POPULATE, $event);
     if ($event->isReset()) {
         $output->writeln(sprintf('<info>Resetting</info> <comment>%s/%s</comment>', $index, $type));
         $this->resetter->resetIndexType($index, $type);
     }
     $offset = $options['offset'];
     $provider = $this->providerRegistry->getProvider($index, $type);
     $loggerClosure = $this->progressClosureBuilder->build($output, 'Populating', $index, $type, $offset);
     $provider->populate($loggerClosure, $event->getOptions());
     $this->dispatcher->dispatch(TypePopulateEvent::POST_TYPE_POPULATE, $event);
     $this->refreshIndex($output, $index, false);
 }
예제 #3
0
 public function testIndexMappingForParent()
 {
     $type = $this->getMockElasticaType();
     $this->indexConfigsByName['parent']['index']->expects($this->once())->method('getType')->with('a')->will($this->returnValue($type));
     $type->expects($this->once())->method('delete');
     $mapping = Mapping::create($this->indexConfigsByName['parent']['config']['properties']['a']['properties']);
     $mapping->setParam('_parent', array('type' => 'b'));
     $type->expects($this->once())->method('setMapping')->with($mapping);
     $resetter = new Resetter($this->indexConfigsByName);
     $resetter->resetIndexType('parent', 'a');
 }
예제 #4
0
 /**
  * @expectedException \InvalidArgumentException
  */
 public function testNonExistantResetType()
 {
     $this->configManager->expects($this->once())->method('getTypeConfiguration')->with('index', 'nonExistant')->will($this->throwException(new \InvalidArgumentException()));
     $this->indexManager->expects($this->never())->method('getIndex');
     $this->resetter->resetIndexType('index', 'nonExistant');
 }