In regards to 1.3 PHP based response writers:

I did see this and included two response interpreters for these in my source (though I wasn't developing against Solr 1.3 so they are more stubs than useable). The Solr_Response follows a factory pattern and automatically chooses the correct Response subclass based on the Content-Type of the HTTP response header. Each subclass then tries to provide the same method of access to the different parts of the response. Both JSON and XML are fully implemented (I found interpretting JSON search responses was fastest for search responses - not to mention the slightly smaller data size)


The license:

I chose the new BSD license because it is the Zend Framework's license. The Apache 2.0 license seems very similar with the exception of how the license and attributions are included. I've changed the license and included the LICENSE and NOTICE files with my source. I just followed the directions at

http://www.apache.org/licenses/LICENSE-2.0.html#apply

Will I or the company need to sign a CLA now as well?


The code:

I attached my source to my email not knowing whether it would come through or not (it was only 7k in a tarball so I thought it was worth a shot). Since it didn't, I'll provide a link below. Also this gives me a change to include PHPdoc files as well which should be a good reference for understanding what I did.

link to files (zip):
http://www.conduit-it.com/Solr/

- Donovan Jimenez


On Aug 16, 2007, at 10:17 PM, Pieter Berkel wrote:

Hi Donovan,

This sounds very promising, I've also recently been working on a php solr
client library for use within my organization but the code is not well
documented nor licensed appropriately just yet.  You may note that
eval()-able and serialized php response writers were recently added to svn trunk (see http://issues.apache.org/jira/browse/SOLR-196 ) so it may be more efficient to use these rather than converting XML / JSON formatted data.

In terms of licensing, I'm not sure if the new BSD license is compatible
with the Apache 2.0 license (see:
http://www.apache.org/licenses/LICENSE-2.0) that Solr is released
under, this would only be an issue if your php
client was to be included in the Solr distribution (which would be useful
but not manditory).

I'd be interested to take a look at your client library code, are you
planning to release it soon?

regards,
Piete



On 17/08/07, Donovan Jimenez <[EMAIL PROTECTED]> wrote:

The company I work for recently started using Solr for some of our
search functionality.  After downloading the files for integrating
with PHP that the Wiki links to I saw that it wasn't usable for our
purposes. So, as part of the project, I developed a PHP Solr Client.
Coming back to the mailing list I see that there was recent talk
about developing a new PHP client, but as of yet I haven't seen it
posted - so I hope I'm not stepping on any toes.  I received
permission from my company to release the code to the community under
the new BSD license.  The coding style is approximately inline with
the Zend Framework's standards  (and somewhat PEAR's) and I feel it's
well documented.

Client Requirements:
  - PHP 5 >= 5.2.0 (we developed on 5.2.1) that has the json_decode
function (available by default as of 5.2) and the XmlReader class
(enabled by default as of 5.1)
  - allow_url_fopen php.ini setting must be enabled (defaults to
enabled)

We'd love to have the community help us maintain this as Solr
evolves. Let us know what you think. Thanks.

- Donovan Jimenez




For those interested:

The starting point is the Solr_Service class. From this class you
have access to all the major functionality of the Solr HTTP service
(add, delete by id, delete by query, commit, optimize and search).
Below I've include a sample of the client's API for searching:


<?php
require_once('Solr/Service.php');

$start = microtime(true);

$solr = new Solr_Service(); //Or explicitly new Solr_Service
('localhost', 8180, '/solr');

try
{
         $response = $solr->search('solr', 0, 10,
                 array(/* you can include other parameters here */));

         echo 'search returned with status = ', $response-
responseHeader->status,
                 ' and took ', microtime(true) - $start, ' seconds',
"\n";

         //here's how you would access results
         //Notice that I've mapped the values by name into a tree of
stdClass objects
         //and arrays (actually most of this is done by json_decode
if the response is
         //in json format - done by an XmlReader loop if its XML)
         if ($response->response->numFound > 0)
         {
                 $doc_number = $response->response->start;

                 foreach ($response->response->docs as $doc)
                 {
                         $doc_number++;

                         echo $doc_number, ': ', $doc->text, "\n";
                 }
         }

         //for the purposes of seeing the available structure of the
response
         //NOTE: Solr_Response::_parsedData is lazy loaded, so a
print_r on the response before
         //any values are accessed may result in different behavior
(in case
         //anyone has some troubles debugging)
         //print_r($response);
}
catch (Exception $e)
{
         echo $e->getMessage(), "\n";
}

?>



Reply via email to