Beispiel #1
0
 private function testSolrConnection()
 {
     $client = new SolariumClient($this->getSolrConfig());
     $ping = $client->createPing();
     try {
         $client->ping($ping);
         return true;
     } catch (Exception $e) {
         return false;
     }
 }
Beispiel #2
0
 public function ping()
 {
     $config = $this->getConfig();
     $solr = new Solarium\Client($config);
     $ping = $solr->createPing();
     try {
         $ping = $solr->ping($ping);
         $ping = $ping->getData();
         $alive = false;
         if (isset($ping['status']) && $ping['status'] === "OK") {
             $alive = true;
         }
     } catch (\Solarium\Exception $e) {
         return false;
     }
     return $alive;
 }
 /**
  * Ping Solr to test if it is working.
  *
  * @return bool - True on success
  */
 public function ping()
 {
     /**
      * This function should not check the $this->_working variable,
      * because it is used to check if everything is working.
      */
     $result = false;
     try {
         $query = $this->_client->createPing();
         // Not 100% sure if this setTimeAllowed works.
         $query->setTimeAllowed(intval($this->getConf('server/search_timeout')));
         $solariumResult = $this->_client->ping($query);
         $this->debugQuery($query);
         $resultData = $solariumResult->getData();
         if (!empty($resultData['status']) && 'OK' === $resultData['status']) {
             $result = true;
         }
     } catch (Exception $e) {
         $this->_lastError = $e;
         Mage::log(sprintf('%s->%s: %s', __CLASS__, __FUNCTION__, $e->getMessage()), Zend_Log::ERR);
     }
     return $result;
 }