Example #1
0
 /**
  * Pings the Solr server using search_solr config
  *
  * @return true|string Returns true if all good or an error string.
  */
 public function is_server_ready()
 {
     $configured = $this->is_server_configured();
     if ($configured !== true) {
         return $configured;
     }
     // Check that the schema is already set up.
     try {
         $schema = new \search_solr\schema();
         $schema->validate_setup();
     } catch (\moodle_exception $e) {
         return $e->getMessage();
     }
     return true;
 }
Example #2
0
 /**
  * Pings the Solr server using search_solr config
  *
  * @return true|string Returns true if all good or an error string.
  */
 public function is_server_ready()
 {
     if (empty($this->config->server_hostname) || empty($this->config->indexname)) {
         return 'No solr configuration found';
     }
     if (!($this->client = $this->get_search_client(false))) {
         return get_string('engineserverstatus', 'search');
     }
     try {
         @$this->client->ping();
     } catch (\SolrClientException $ex) {
         return 'Solr client error: ' . $ex->getMessage();
     } catch (\SolrServerException $ex) {
         return 'Solr server error: ' . $ex->getMessage();
     }
     // Check that setup schema has already run.
     try {
         $schema = new \search_solr\schema();
         $schema->validate_setup();
     } catch (\moodle_exception $e) {
         return $e->getMessage();
     }
     return true;
 }