More about endpoints
Solarium provides us with the flexibility of adding multiple Solr servers as endpoints and using a single Solarium client to fire query on any Solr server. To add another endpoint to our Solarium configuration for Solr running on another port 8983
on our localhost
and to use it to execute our query, we will use the following code:
$config = array( "endpoint" => array( "localhost" => array("host"=>"127.0.0.1","port"=>"8080","path"=>"/solr", "core"=>"collection1",), "localhost2" => array("host"=>"127.0.0.1","port"=>"8983","path"=>"/solr", "core"=>"collection1",) ) ); $result = $client->ping($ping, "localhost2");
The Solarium client provides functionality of adding and removing endpoints using the addEndpoint(array $endpointConfig)
and removeEndpoint(string $endpointName)
functions. To modify an endpoint during runtime, we can call getEndpoint(String $endPointName)
to get the endpoint and the use functions such as setHost(String $host)
, setPort(int $port)
, setPath(String $path)
, and setCore(String $core)
to change the endpoint settings. Additional settings provided for endpoints are:
The
setTimeout(int $timeout)
setting is used for specifying a timeout for a Solr connectionThe
setAuthentication(string $username, string $password)
setting is used for providing authentication if your Solr or Tomcat requires HTTP authenticationThe
setDefaultEndpoint(string $endpoint)
setting can be used to set the default endpoint for a Solarium client