Ejemplo n.º 1
0
 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));
 }
Ejemplo n.º 2
0
 /**
  * Adds an alias to the current index
  *
  * @param  string            $name    Alias name
  * @param  bool              $replace OPTIONAL If set, an existing alias will be replaced
  * @return Elastica_Response Response
  * @link http://www.elasticsearch.org/guide/reference/api/admin-indices-aliases.html
  */
 public function addAlias($name, $replace = false)
 {
     $path = '_aliases';
     if ($replace) {
         $status = new Elastica_Status($this->getClient());
         foreach ($status->getIndicesWithAlias($name) as $index) {
             $index->removeAlias($name);
         }
     }
     $data = array('actions' => array(array('add' => array('index' => $this->getName(), 'alias' => $name))));
     return $this->getClient()->request($path, Elastica_Request::POST, $data);
 }