public function testAliasExists() { $indexName = 'test'; $aliasName = 'elastica_test-alias'; $index1 = $this->_createIndex(); $status = new Elastica_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)); }
public function testReplaceAlias() { $indexName1 = 'test1'; $indexName2 = 'test2'; $aliasName = 'test-alias'; $client = new Elastica_Client(); $index1 = $client->getIndex($indexName1); $index2 = $client->getIndex($indexName2); $index1->create(array(), true); $index1->addAlias($aliasName); $index2->create(array(), true); $status = new Elastica_Status($client); $this->assertTrue($status->indexExists($indexName1)); $this->assertTrue($status->indexExists($indexName2)); $this->assertTrue($status->aliasExists($aliasName)); $this->assertTrue($index1->getStatus()->hasAlias($aliasName)); $this->assertFalse($index2->getStatus()->hasAlias($aliasName)); $index2->addAlias($aliasName, true); $this->assertFalse($index1->getStatus()->hasAlias($aliasName)); $this->assertTrue($index2->getStatus()->hasAlias($aliasName)); }