public function testAliasExists() { $indexName = 'test'; $aliasName = 'elastica_test-alias'; $index1 = $this->_createIndex(); $status = new Status($index1->getClient()); foreach ($status->getIndicesWithAlias($aliasName) as $tmpIndex) { $tmpIndex->removeAlias($aliasName); } $this->assertFalse($status->aliasExists($aliasName)); $index1->addAlias($aliasName); $status->refresh(); $this->assertTrue($status->aliasExists($aliasName)); }
/** * @group functional */ public function testAliasExists() { $aliasName = 'elastica_test-alias'; $index1 = $this->_createIndex(); $indexName = $index1->getName(); $status = new Status($index1->getClient()); foreach ($status->getIndicesWithAlias($aliasName) as $tmpIndex) { $tmpIndex->removeAlias($aliasName); } $this->assertFalse($status->aliasExists($aliasName)); $index1->addAlias($aliasName); $status->refresh(); $this->assertTrue($status->aliasExists($aliasName)); $indicesWithAlias = $status->getIndicesWithAlias($aliasName); $this->assertEquals(array($indexName), array_map(function ($index) { return $index->getName(); }, $indicesWithAlias)); }
public function testDeleteIndexDeleteAlias() { $indexName = 'test'; $aliasName = 'test-aliase'; $client = $this->_getClient(); $index = $client->getIndex($indexName); $index->create(array(), true); $index->addAlias($aliasName); $status = new Status($client); $this->assertTrue($status->indexExists($indexName)); $this->assertTrue($status->aliasExists($aliasName)); // Deleting index should also remove alias $index->delete(); $status->refresh(); $this->assertFalse($status->indexExists($indexName)); $this->assertFalse($status->aliasExists($aliasName)); }
/** * Refresh elastica status */ protected function refreshStatus() { if ($this->status) { $this->status->refresh(); } }