lib/Elastica/Index.php
public function addAlias($name, $replace = false)
    {
        $data = ['actions' => []];

        if ($replace) {
            $status = new Status($this->getClient());
            foreach ($status->getIndicesWithAlias($name) as $index) {
                $data['actions'][] = ['remove' => ['index' => $index->getName(), 'alias' => $name]];
            }
        }

        $data['actions'][] = ['add' => ['index' => $this->getName(), 'alias' => $name]];

        $endpoint = new Update();
        $endpoint->setBody($data);

        return $this->getClient()->requestEndpoint($endpoint);
    }
public function addAlias($name, $replace = false)
    {
        $data = ['actions' => []];

        if ($replace) {
            $status = new Status($this->getClient());
            foreach ($status->getIndicesWithAlias($name) as $index) {
                $data['actions'][] = ['remove' => ['index' => $index->getName(), 'alias' => $name]];
            }
        }

        $data['actions'][] = ['add' => ['index' => $this->getName(), 'alias' => $name]];

        $endpoint = new Update();
        $endpoint->setBody($data);

        return $this->getClient()->requestEndpoint($endpoint);
    }
public function addAlias ( $ name , $ replace = false ) { $ data = [ 'actions' => [ ] ] ; if ( $ replace ) { $ status = new Status ( $ this -> getClient ( ) ) ; foreach ( $ status -> getIndicesWithAlias ( $ name ) as $ index ) { $ data [ 'actions' ] [ ] = [ 'remove' => [ 'index' => $ index -> getName ( ) , 'alias' => $ name ] ] ; } } $ data [ 'actions' ] [ ] = [ 'add' => [ 'index' => $ this -> getName ( ) , 'alias' => $ name ] ] ; $ endpoint = new Update ( ) ; $ endpoint -> setBody ( $ data ) ; return $ this -> getClient ( ) -> requestEndpoint ( $ endpoint ) ; }
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

@see https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-aliases.html
Adds an alias to the current index .