hacioguz / solr-php-client

Automatically exported from code.google.com/p/solr-php-client
Other
0 stars 0 forks source link

the Solr return invalid json with empty non string value #27

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
the Solr return invalid json with empty non string value

Index: SolrPhpClient/Apache/Solr/Response.php
===================================================================
--- SolrPhpClient/Apache/Solr/Response.php  (revision 24)
+++ SolrPhpClient/Apache/Solr/Response.php  (working copy)
@@ -247,6 +247,11 @@
        //An alternative would be to use Zend_Json::decode(...)
        $data = json_decode($this->_rawResponse);

+    if($data === null)
+    {
+      // the Solr return invalid json with empty non string value
+      throw new Exception('JSON is not valid.');
+    }
        //if we're configured to collapse single valued arrays or to convert
them to Apache_Solr_Document objects
        //and we have response documents, then try to collapse the values and /
or convert them now
        if (($this->_createDocuments || $this->_collapseSingleValueArrays) &&
isset($data->response) && is_array($data->response->docs))

Original issue reported on code.google.com by thomas.r...@gmail.com on 23 Nov 2009 at 4:47

GoogleCodeExporter commented 8 years ago
I can't think of a situation where Solr should be returning empty response body 
with a 200 response status. Can 
you provide information on what leads to this behavior for you? it may be a bug 
in Solr that we should report to 
them.

Original comment by donovan....@gmail.com on 23 Nov 2009 at 8:27

GoogleCodeExporter commented 8 years ago
I have a document with longitude and latitude fields declared as float. If php 
set the value to null then the solr 
engine (1.3) return a non valid json :

{
 longitude:,
 latitude:
}

read : 
http://svn.apache.org/repos/asf/lucene/solr/tags/release-1.4.0/CHANGES.txt 
(SOLR-125)

Throwing an error might help to found out the bug ;)

Original comment by thomas.r...@gmail.com on 23 Nov 2009 at 8:50

GoogleCodeExporter commented 8 years ago
Fixed in r25

Original comment by donovan....@gmail.com on 10 Dec 2009 at 3:49