Last active
October 19, 2015 10:50
-
-
Save algotrader-dotcom/7ce7a302e0a705bdff89 to your computer and use it in GitHub Desktop.
Solarium PHP client configuration
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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