public open ( ) |
public function open()
{
if ($this->activeNode !== null) {
return;
}
if (empty($this->nodes)) {
throw new InvalidConfigException('elasticsearch needs at least one node to operate.');
}
$this->_curl = curl_init();
if ($this->autodetectCluster) {
$this->populateNodes();
}
$this->selectActiveNode();
Yii::trace('Opening connection to elasticsearch. Nodes in cluster: ' . count($this->nodes) . ', active node: ' . $this->nodes[$this->activeNode]['http_address'], __CLASS__);
$this->initConnection();
}
/** * @param boolean $reset whether to clean up the test database * @return Connection */ public function getConnection($reset = true) { $databases = self::getParam('databases'); $params = isset($databases['elasticsearch']) ? $databases['elasticsearch'] : []; $db = new Connection(); if ($reset) { $db->open(); } return $db; }