Exemple #1
0
 /**
  * Shows the status of the core according to solr
  */
 protected function _status()
 {
     $url = Solr::base() . '/admin/cores?';
     $params = array('action' => 'STATUS', 'core' => $this->solr->config->index_name());
     $resp = Solr::curl_request($url . http_build_query($params));
     $xml = new DOMDocument('1.0', 'UTF-8');
     $xml->loadXML($resp);
     $this->show_status($xml, $this->solr->config->index_name());
 }
Exemple #2
0
 public function create()
 {
     if ($this->ping()) {
         // auto deleting is a little to risky.. so lets throw an error.
         throw new Solr_Exception('Core ":core" exists, delete the previous before recreating', array(':core' => $this->config->index_name()));
     }
     // make folder and files
     $this->make();
     $url = Solr::base();
     $path = '/admin/cores';
     $params = array('action' => 'CREATE', 'name' => $this->config->index_name(), 'instanceDir' => $this->config->index_name() . '/', 'dataDir' => './data');
     $resp = Solr::curl_request($url . $path . '?' . http_build_query($params));
     $doc = new DOMDocument('1.0');
     $doc->formatOutput = TRUE;
     $doc->loadXML($resp);
     $response = $doc->getElementsByTagName('response') && $doc->getElementsByTagName('response')->item(0) ? $doc->getElementsByTagName('response')->item(0) : false;
     if (!$response) {
         //throw new Solr_Exception('Invalid Response occured');
         return false;
     }
     $status = $response->getElementsByTagName('int')->item(0);
     $qtime = $response->getElementsByTagName('int')->item(1);
     $core = $response->getElementsByTagName('str')->item(0);
     $obj = new stdClass();
     $obj->status = $status->nodeValue;
     $obj->time = $qtime->nodeValue;
     $obj->core = $core->nodeValue;
     return $obj->status == 0 && $obj->core == $this->config->index_name() ? $obj : false;
 }