/** * final because else it could seriously damage the Index in the unlikely case there's already an index named typo3_ElasticSearch_FunctionalTests */ public final function setUp() { parent::setUp(); $this->clientFactory = $this->objectManager->get('Flowpack\\ElasticSearch\\Domain\\Factory\\ClientFactory'); $client = $this->clientFactory->create(); $this->testingIndex = $client->findIndex('typo3_elasticsearch_functionaltests'); if ($this->testingIndex->exists()) { throw new \Exception('The index "typo3_elasticsearch_functionaltests" already existed, aborting.', 1338967487); } else { $this->testingIndex->create(); $this->removeIndexOnTearDown = TRUE; } $this->additionalSetUp(); }
/** * Refresh an index in ElasticSearch * * @param string $indexName The name of the index to be removed * @param string $clientName The client name to use */ public function refreshCommand($indexName, $clientName = null) { if (!in_array($indexName, $this->indexInformer->getAllIndexNames())) { $this->outputFormatted("The index <b>%s</b> is not configured in the current application", array($indexName)); } $client = $this->clientFactory->create($clientName); try { $index = new Index($indexName, $client); if (!$index->exists()) { $this->outputFormatted("The index <b>%s</b> does not exists", array($indexName)); $this->quit(1); } $index->refresh(); $this->outputFormatted("Index <b>%s</b> refreshed with success", array($indexName)); } catch (Exception $exception) { $this->outputFormatted("Unable to refresh an index named: <b>%s</b>", array($indexName)); $this->quit(1); } }