Skip to content

Instantly share code, notes, and snippets.

@algotrader-dotcom
Last active October 19, 2015 10:50
Show Gist options
  • Select an option

  • Save algotrader-dotcom/7ce7a302e0a705bdff89 to your computer and use it in GitHub Desktop.

Select an option

Save algotrader-dotcom/7ce7a302e0a705bdff89 to your computer and use it in GitHub Desktop.
Solarium PHP client configuration
# Install Solarium-Client
$ yum install composer
$ vi composer.json
{
"require": {
"solarium/solarium": "2.4.0"
}
}
$ composer install
#
# Code examples
#
<?php
require('/path/to/library/Solarium/Autoloader.php');
Solarium_Autoloader::register();
$config = array(
'adapteroptions' => array(
'host' => 'admin:admin@127.0.0.1',
'port' => 8984,
'path' => '/solr/corename'
)
);
$client = new Solarium_Client();
// create a client instance
$client = new Solarium_Client($config);
// get a select query instance
$query = $client->createSelect();
// this executes the query and returns the result
$resultset = $client->select($query);
// display the total number of documents found by solr
echo 'NumFound: '.$resultset->getNumFound();
// ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment