SOLR PHP Support
Contents
SOLR PHP support solr-php-client Apache solr php Extension solarium solr ' s PHP response format SOLR ' s PHP serialized RESPO NSE Format Historical
Solr-php-client
A 3rd party PHP Library for indexing and searching documents within A Apache SOLR installation.
Zip/tarballs can found at solrphpclient
Adding, Deleting (by ID and query), committing, optimizing and of course searching against a SOLR instance written for PHP 5 in Zend framework/pear coding style PHPDOC generated API documentation included see link above for example usage and Further documentation
Apache SOLR PHP Extension
The Apache SOLR PECL extension is a light-weight, Feature-rich library that allows developers using Apache SOLR via PHP to Communicate easily and efficiently with the SOLR Web service using a object-oriented API.
The documentation for the PECL extension contains instructions on what to install the extension and are available in the PHP Manual under Search Engine Extensions.
Sometimes, the official documentation a while to update. The documentation for the SOLR PECL extension are constantly being updated from time to time.
If you is unable to find some information on the official PHP manual, please check here
The latest version of the PECL extension is 0.9.7 (2009-11-17)
The PHP extension can downloaded from the Apache SOLR PECL Project home page.
Thanks to Pierre-alain Joye from Php.net, the Windows DLLs for PHP 5.3 can is downloaded here
Http://downloads.php.net/pierre/
A Quick List of some of the features of the API include:
Built in support for adding, deleting, optimizing, searching, rollback. Ability to connect to SOLR servers behind ssl-enabled containers. Users can optionally provide pem-formatted private keys or certificates to connect in HTTPS mode. Users can optionally provide CA certificates to authenticate hostname and issuer of SSL certificate.
Developers can now update the values of the servlets (such as search, update) after the Solrclient instance have been creat Ed.
Built in, Serializable query string builder objects which effectively simplifies the manipulation of Name-value pair Reque St parameters across repeated requests.
The Query Builder API has methods to Add/set, remove or retrieve Name-value pair values for the following features in SOLR : Simplefacetparameters,statscomponent, Morelikethis, highlightingparameters, termscomponent etc.
Ability to reuse of HTTP connections across repeated requests (within the same thread in ZTS mode or same process in non-z TS mode). Advanced HTTP client This provides built-in support for connecting to SOLR servers secured behind HTTP authentication or H TTP proxy servers.
Ability to obtain Solrinputdocument objects from Solrdocument in query response for possible resubmission or updates.
Automatic parsing of SOLR response into native PHP objects whose properties can be accessed as array keys or object proper Ties without any additional configuration on the client-side. This is simplified interface to access server response data. SOLR Objects can be treated as arrays or Objects.
Also the solrdocument retrieved from the query response implements the following interfaces which gives the developer Seve RAL options on how to manipulate the response:arrayaccess, Iterator, traversable, Serializable.
The extension currently uses version 2.2 of the XML response format internally.
The contents of the XML response is transformed to native PHP types and the result is returned as a SOLR Object instance .
Also install it by running the following command in the console:
$ pecl Install Solr-beta
Solarium
Solarium is a SOLR client library for PHP applications This not only facilitates SOLR communication but also tries to ACCU Rately model SOLR Concepts.
SOLR ' s PHP response format
SOLR has a PHP response format this outputs an array (as PHP code) which can be eval ' d.
Example usage:
$code = file_get_contents (' http://localhost:8983/solr/select?q=iPod&wt=php '); eval ("\ $result =". $code. ";"); Print_r ($result);
SOLR ' s PHP serialized response format
SOLR have a PHP response format that outputs a serialized array.
Example usage:
$serializedResult = file_get_contents (' Http://localhost:8983/solr/select?q=iPod&wt=phps '); $result = Unserialize ($serializedResult);p rint_r ($result);
In order to use either PHP or serialized PHP Response writers, the first need to uncomment these and the lines in your Sol Rconfig.xml:
can also use the new response writer plugin for PHP here
https://issues.apache.org/jira/browse/SOLR-1967
!--You can choose a different class for your objects. Just Make sure the class was available in the client-->
Solrobject
!--0 means object_properties_storage_mode_independent1 means Object_properties_storage_mode_combinedin independed MODE, Each property is a separate Propertyin combined mode, and all the properites be merged into a _properties array. The combined mode allows you-to-create custom __getters and you could also implement Arrayaccess, Iterator and traversable -->
0
Also Check out how to use it on the client side here
Http://www.php.net/manual/en/solrclient.setresponsew riter.php
http://www.php.net/manual/en/solrclient.construct.php
Categoryqueryresponsewriter
Historical Original Client Code contributed by Brian Lucas:
There is, classes for php:solrupdate and S Olrquery.
: TODO:
-Clean up some of the XML writing code--it's a tad "kludgy" right now.
-Abstract out more than the logic into configurable variables
-Add back in the logging and debugging classes The "echo" calls