addAlias() public method

Adds an alias to the current index.
public addAlias ( string $name, boolean $replace = false ) : Response
$name string Alias name
$replace boolean OPTIONAL If set, an existing alias will be replaced
return Response Response
Example #1
0
 protected function setUp()
 {
     parent::setUp();
     $this->_index1 = $this->_createIndex('indices_filter_1');
     $this->_index2 = $this->_createIndex('indices_filter_2');
     $this->_index1->addAlias("indices_filter");
     $this->_index2->addAlias("indices_filter");
     $docs = array(new Document("1", array("color" => "blue")), new Document("2", array("color" => "green")), new Document("3", array("color" => "blue")), new Document("4", array("color" => "yellow")));
     $this->_index1->getType("test")->addDocuments($docs);
     $this->_index2->getType("test")->addDocuments($docs);
     $this->_index1->refresh();
     $this->_index2->refresh();
 }
Example #2
0
 /**
  * @param ElasticIndex $oldIndex
  * @param ElasticIndex $newIndex
  */
 private function moveAliasBetweenIndices(ElasticIndex $oldIndex, ElasticIndex $newIndex)
 {
     $oldIndex->removeAlias(MappingCreator::ELASTIC_ALIAS);
     $newIndex->addAlias(MappingCreator::ELASTIC_ALIAS);
 }