Details

    • Type: New Feature New Feature
    • Status: Resolved
    • Priority: Trivial Trivial
    • Resolution: Invalid
    • Affects Version/s: 1.2
    • Fix Version/s: 1.5
    • Component/s: clients - php
    • Labels:
      None
    • Environment:

      PHP >= 5.2.0 (or older with JSON PECL extension or other json_decode function implementation). Solr >= 1.2

      Description

      Since I'm unable to currently update the Solr WIKI page that points to this issue and its downloads, I've left this issue open. I, however, need to note that active releases of the PHP code are now available from:

      http://code.google.com/p/solr-php-client/downloads/list

      If you have any issues specific to this PHP client, please post / discuss them there (or on the solr user mailing list - I am a subscriber).

        Activity

        Hide
        Donovan Jimenez added a comment -

        Source code, license stuff, and PHPDocs

        Show
        Donovan Jimenez added a comment - Source code, license stuff, and PHPDocs
        Hide
        Donovan Jimenez added a comment -

        Attaching a new zip because previous had bug in Solr_Service::escape function

        Show
        Donovan Jimenez added a comment - Attaching a new zip because previous had bug in Solr_Service::escape function
        Hide
        Donovan Jimenez added a comment -

        Updates to the Solr Client:

        • search can now take muliple parameters of the same name, such as when using facets
        • ping now can take a timeout value which acts as a maximum time allowed to wait for a response
        • namespace change to Apache_Solr to avoid confusion with php Solar (unrelated) project
        • Apache_Solr_Document now implements iterator interface, so its fields can be foreach'd
        • Reference implementation of a read from slave / write to master balancer has be added
        Show
        Donovan Jimenez added a comment - Updates to the Solr Client: search can now take muliple parameters of the same name, such as when using facets ping now can take a timeout value which acts as a maximum time allowed to wait for a response namespace change to Apache_Solr to avoid confusion with php Solar (unrelated) project Apache_Solr_Document now implements iterator interface, so its fields can be foreach'd Reference implementation of a read from slave / write to master balancer has be added
        Hide
        Donovan Jimenez added a comment -

        Updates to PHP client

        • fixes Apache_Solr_Document::setMultiValue typo
        • Apache_Solr_Service_Balancer fixes
        • Apache_Solr_Service / Apache_Solr_Response now use the json.nl parameter for NamedList handling at the Solr server side instead of doing PHP client side
        • Apache_Solr_Service::commit() method signature has changed for optimize parameter
        • Included a Changelog file generated from subversion
        Show
        Donovan Jimenez added a comment - Updates to PHP client fixes Apache_Solr_Document::setMultiValue typo Apache_Solr_Service_Balancer fixes Apache_Solr_Service / Apache_Solr_Response now use the json.nl parameter for NamedList handling at the Solr server side instead of doing PHP client side Apache_Solr_Service::commit() method signature has changed for optimize parameter Included a Changelog file generated from subversion
        Hide
        Mark Lindeman added a comment - - edited

        it would be nice to have support for custom instances of StandardRequestHandler. Apache_Solr_Service now uses a class constant SEARCH_SERVLET to build it's query.

        A quick fix would be:
        add extra parameter to function search:
        public function search($query, $offset = 0, $limit = 10, $params = array(), $search_servlet = null)

        and change last line of this function to:
        $searchUrl = $search_servlet==null ? $this->_searchUrl : $this->_constructUrl($search_servlet);
        return $this->_sendRawGet($searchUrl . $this->_queryDelimiter . $queryString);

        Another wish:
        please make your methods and object variables "protected" in stead of "private" so we can extend your great Class.

        Show
        Mark Lindeman added a comment - - edited it would be nice to have support for custom instances of StandardRequestHandler. Apache_Solr_Service now uses a class constant SEARCH_SERVLET to build it's query. A quick fix would be: add extra parameter to function search: public function search($query, $offset = 0, $limit = 10, $params = array(), $search_servlet = null) and change last line of this function to: $searchUrl = $search_servlet==null ? $this->_searchUrl : $this->_constructUrl($search_servlet); return $this->_sendRawGet($searchUrl . $this->_queryDelimiter . $queryString); Another wish: please make your methods and object variables "protected" in stead of "private" so we can extend your great Class.
        Hide
        Donovan Jimenez added a comment -

        Made private members and functions protected so that they could be used / overridden by subclasses. See included changelog for other changes.

        Show
        Donovan Jimenez added a comment - Made private members and functions protected so that they could be used / overridden by subclasses. See included changelog for other changes.
        Hide
        Rich R added a comment - - edited

        Hi

        I've encountered an issue in the _documentToXmlFragment() method of the Apache_Solr_Service class.

        To cut a long story short, I'm building up documents from database rows, some of which contain NULL values. I've noticed that NULL values interfere with the following (Iterator-based) code in the above method:

        foreach ($document as $key => $value)
        {
        ...

        What basically happens is that a NULL $value seems to cause the foreach loop to terminate prematurely. Any fields 'beyond' that with the NULL value do not get added to the index.

        The very simple workaround for this was to replace the above code fragment with the following:

        $keys = $document->getFieldNames();
        foreach ($keys as $key)
        {
        $value = $document->$key;
        ...

        As you can see, it's essentially the same, and fully backwards-compatible. It just avoids the issue I've been experiencing with the iterator.

        I'd really like to see this change make it to the code if possible (I can submit a patch if necessary).

        For reference, I'm using PHP 5.3 on OSX.

        Best regards
        Rich

        Show
        Rich R added a comment - - edited Hi I've encountered an issue in the _documentToXmlFragment() method of the Apache_Solr_Service class. To cut a long story short, I'm building up documents from database rows, some of which contain NULL values. I've noticed that NULL values interfere with the following (Iterator-based) code in the above method: foreach ($document as $key => $value) { ... What basically happens is that a NULL $value seems to cause the foreach loop to terminate prematurely. Any fields 'beyond' that with the NULL value do not get added to the index. The very simple workaround for this was to replace the above code fragment with the following: $keys = $document->getFieldNames(); foreach ($keys as $key) { $value = $document->$key; ... As you can see, it's essentially the same, and fully backwards-compatible. It just avoids the issue I've been experiencing with the iterator. I'd really like to see this change make it to the code if possible (I can submit a patch if necessary). For reference, I'm using PHP 5.3 on OSX. Best regards Rich
        Hide
        Donovan Jimenez added a comment -

        Rich Robinson helped me to track down an issue where he found that documents with values = false were creating prematurely exiting foreach loops (when iterating a document). I determined it was the valid() implementation of the Iterator iterface, and after fussing with it decided to just implement IteratorAggregator instead and use the pre-existing SPL ArrayIterator class. This simplifies the Apache_Solr_Document code and now all document values are looped even when some are false.

        Show
        Donovan Jimenez added a comment - Rich Robinson helped me to track down an issue where he found that documents with values = false were creating prematurely exiting foreach loops (when iterating a document). I determined it was the valid() implementation of the Iterator iterface, and after fussing with it decided to just implement IteratorAggregator instead and use the pre-existing SPL ArrayIterator class. This simplifies the Apache_Solr_Document code and now all document values are looped even when some are false.
        Hide
        Pieter Berkel added a comment -

        Hi Donovan,

        Great work on the PHP client library, however I noticed that there is no way to specify document- and/or field-level boost values when creating and indexing documents:

        http://wiki.apache.org/solr/UpdateXmlMessages

        Perhaps Apache_Solr_Document could have a constructor method with an optional parameter for setting the document boost:

        public function __construct($boost = '1.0') {

        Not so sure how the field-level boost should be set, maybe add methods setFieldBoost($key) and getFieldBoost($key) to Apache_Solr_Document?

        If necessary I can also submit code patches for these changes.

        cheers,
        Piete

        Show
        Pieter Berkel added a comment - Hi Donovan, Great work on the PHP client library, however I noticed that there is no way to specify document- and/or field-level boost values when creating and indexing documents: http://wiki.apache.org/solr/UpdateXmlMessages Perhaps Apache_Solr_Document could have a constructor method with an optional parameter for setting the document boost: public function __construct($boost = '1.0') { Not so sure how the field-level boost should be set, maybe add methods setFieldBoost($key) and getFieldBoost($key) to Apache_Solr_Document? If necessary I can also submit code patches for these changes. cheers, Piete
        Hide
        Donovan Jimenez added a comment -

        Added additional functionality to Apache_Solr_Document and Apache_Solr_Service for document and field based boost values.

        $doc = new Apache_Solr_Document();
        
        // can set document boost 
        $doc->setBoost(1.5);
        
        // can set a field boost at value assignment time
        $doc->setField('foo', 'bar', 1.3);
        
        // or as a separate call
        $doc->setFieldBoost('foo', 3.141579);
        
        Show
        Donovan Jimenez added a comment - Added additional functionality to Apache_Solr_Document and Apache_Solr_Service for document and field based boost values. $doc = new Apache_Solr_Document(); // can set document boost $doc->setBoost(1.5); // can set a field boost at value assignment time $doc->setField('foo', 'bar', 1.3); // or as a separate call $doc->setFieldBoost('foo', 3.141579);
        Hide
        Pieter Berkel added a comment -

        Thanks for the quick response, just wanted to check that you uploaded the updated class files? I couldn't find the new setBoost() / setField() / setFieldBoost() methods in the Document class located in SolrPhpClient.2008-11-24.zip

        Show
        Pieter Berkel added a comment - Thanks for the quick response, just wanted to check that you uploaded the updated class files? I couldn't find the new setBoost() / setField() / setFieldBoost() methods in the Document class located in SolrPhpClient.2008-11-24.zip
        Hide
        Donovan Jimenez added a comment -

        You are correct, I didn't zip up the updated files. I did the work on a branch, but my build script takes from trunk.

        This new one should be what you want - i double checked , sorry for the confusion.

        Show
        Donovan Jimenez added a comment - You are correct, I didn't zip up the updated files. I did the work on a branch, but my build script takes from trunk. This new one should be what you want - i double checked , sorry for the confusion.
        Hide
        Mark Lindeman added a comment -

        in Apache/Solr/Document.php on line 218:
        $this->_fieldBoosts = $boost;

        this should be:
        $this->_fieldBoosts[$key] = $boost;

        If I do not use the $fieldboost parameter in setField() method, than I end up with a document full off boost="" parameters which triggers errors in Solr 1.3

        Show
        Mark Lindeman added a comment - in Apache/Solr/Document.php on line 218: $this->_fieldBoosts = $boost; this should be: $this->_fieldBoosts [$key] = $boost; If I do not use the $fieldboost parameter in setField() method, than I end up with a document full off boost="" parameters which triggers errors in Solr 1.3
        Hide
        Shalin Shekhar Mangar added a comment -

        Marked for 1.5

        Show
        Shalin Shekhar Mangar added a comment - Marked for 1.5
        Hide
        Nick Martin added a comment -

        Revision 5 of PhpSolrClient is used by the apachesolr Drupal module (http://drupal.org/project/apachesolr). That revision of the code is absent from this site, but the apachesolr readme.txt lists downloading code from here as a viable option. Unfortunately the older versions of the code posted here do not work. Could you please post revision 5 here?

        Thanks!

        Show
        Nick Martin added a comment - Revision 5 of PhpSolrClient is used by the apachesolr Drupal module ( http://drupal.org/project/apachesolr ). That revision of the code is absent from this site, but the apachesolr readme.txt lists downloading code from here as a viable option. Unfortunately the older versions of the code posted here do not work. Could you please post revision 5 here? Thanks!
        Hide
        Peter Wolanin added a comment -

        r6 has been bundled into a release: http://code.google.com/p/solr-php-client/downloads/list

        We'll test this with the Drupal module soon, but is likely to work fine.

        Show
        Peter Wolanin added a comment - r6 has been bundled into a release: http://code.google.com/p/solr-php-client/downloads/list We'll test this with the Drupal module soon, but is likely to work fine.
        Hide
        Donovan Jimenez added a comment -

        updated issue text to reflect new file hosting on Google Code.

        Show
        Donovan Jimenez added a comment - updated issue text to reflect new file hosting on Google Code.
        Hide
        Donovan Jimenez added a comment -

        Now that the Solr integration in PHP wiki page is updated to reflect the new download location for the client this issue no longer needs to stay open.

        Show
        Donovan Jimenez added a comment - Now that the Solr integration in PHP wiki page is updated to reflect the new download location for the client this issue no longer needs to stay open.

          People

          • Assignee:
            Unassigned
            Reporter:
            Donovan Jimenez
          • Votes:
            5 Vote for this issue
            Watchers:
            8 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development