You are here

public function Apache_Solr_Service_Balancer::search in Apache Solr Search 5

Simple Search interface

Parameters

string $query The raw query string:

int $offset The starting offset for result documents:

int $limit The maximum number of result documents to return:

array $params key / value pairs for query parameters, use arrays for multivalued parameters:

Return value

Apache_Solr_Response

Throws

Exception If an error occurs during the service call

File

SolrPhpClient/Apache/Solr/Service/Balancer.php, line 723

Class

Apache_Solr_Service_Balancer
Reference Implementation for using multiple Solr services in a distribution. Functionality includes: routing of read / write operations failover (on selection) for multiple read servers

Code

public function search($query, $offset = 0, $limit = 10, $params = array()) {
  $service = $this
    ->_selectReadService();
  do {
    try {
      return $service
        ->search($query, $offset, $limit, $params);
    } catch (Exception $e) {
      if ($e
        ->getCode() != 0) {

        //IF NOT COMMUNICATION ERROR
        throw $e;
      }
    }
    $service = $this
      ->_selectReadService(true);
  } while ($service);
  return false;
}