yii\elasticsearch\Connection::open PHP Method

open() public method

It does nothing if a DB connection has already been established.
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();
    }

Usage Example

 /**
  * @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;
 }
All Usage Examples Of yii\elasticsearch\Connection::open