/** * @see Symfony\Component\Console\Command\Command::execute() */ protected function execute(InputInterface $input, OutputInterface $output) { $index = $input->getOption('index'); $force = (bool) $input->getOption('force'); $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 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']['mappings']['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'); }
/** * 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'); 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); } } }
/** * 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) { if ($reset) { $output->writeln(sprintf('<info>Resetting</info> <comment>%s/%s</comment>', $index, $type)); $this->resetter->resetIndexType($index, $type); } $loggerClosure = function ($message) use($output, $index, $type) { $output->writeln(sprintf('<info>Populating</info> %s/%s, %s', $index, $type, $message)); }; $provider = $this->providerRegistry->getProvider($index, $type); $provider->populate($loggerClosure, $options); $output->writeln(sprintf('<info>Refreshing</info> <comment>%s</comment>', $index)); $this->indexManager->getIndex($index)->refresh(); }