/** * @return bool */ public function testConnection() { $connection = new \Elastica\Connection(['port' => $this->port]); $request = new \Elastica\Request('_status', \Elastica\Request::GET); $request->setConnection($connection); $result = true; try { $request->send(); } catch (ErrorException $e) { $result = false; } return $result; }
/** * Performs suggest query for specified text query. * * @param string $q * @return \Elastica\Response */ public function suggest($q) { $params = array('text' => $q, 'simple_phrase' => array('phrase' => array('field' => $this->_helper->getSuggestFieldName(), 'max_errors' => 0.9))); $suggest = new \Elastica\Request($this->_index . '/_suggest', \Elastica\Request::POST, $params); $suggest->setConnection($this->getConnection()); return $suggest->send(); }