|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #59147 MoreLikeThis only parses one doc
Submitted: 2010-04-06 15:30 UTC Modified: 2010-04-27 23:14 UTC
From: max at blubolt dot com Assigned: iekpo (profile)
Status: Closed Package: solr (PECL)
PHP Version: 5.2.12 OS: Ubuntu Karmic, Gentoo
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem:
39 - 21 = ?
Subscribe to this entry?

 [2010-04-06 15:30 UTC] max at blubolt dot com
To confirm, this happens on both 0.9.9 and on SVN latest.

We're sending a request for MoreLikeThis data - 
ntone-keyring2)&fq=siteId:bloomsbury AND 
userType:regular_display&terms.sort=count&fl=id - which is 
being handled just fine by your library and by Solr, and is 
returning an XML document (see the attached 

Unfortunately, SolrQuery::getResponse then throws a warning 
level error of 
	"Error unserializing raw response.", 
which is also thrown when using 

The issue appears to arise when more than one document is 
returned by a MoreLikeThis query - if the 
below result is stripped down to a single Doc element within  
<result name="pantone-keyring2" 
numFound="2693" start="0">, it parses without issue.

Reproduce code:
Do a MoreLikeThisQuery, or just use digestXMLResponse on

<?xml version="1.0" encoding="UTF-8"?>

<lst name="responseHeader">
 <int name="status">0</int>
 <int name="QTime">3</int>
 <lst name="params">
  <str name="mlt.minwl">1</str>
  <str name="mlt.boost">true</str>
  <str name="mlt.fl">metaSimilarity</str>
  <str name="indent">on</str>
  <str name="mlt.mintf">1</str>
  <str name="mlt">true</str>
  <str name="wt">xml</str>
  <str name="terms.sort">count</str>
  <str name="version">2.2</str>
  <str name="mlt.mindf">1</str>
  <str name="mlt.count">10</str>
  <str name="fl">id</str>
  <str name="q">id:(pantone-keyring2)</str>
  <str name="fq">siteId:bloomsbury AND userType:regular_display</str>
<result name="response" numFound="1" start="0">
  <str name="id">pantone-keyring2</str>
<lst name="moreLikeThis">
 <result name="pantone-keyring2" numFound="2693" start="0">
	<str name="id">pantone-keyring4</str>
	<str name="id">pantone-keyring3</str>
	<str name="id">pantone-keyring1</str>
	<str name="id">pantone-keyring45</str>
	<str name="id">pantone-keyring6</str>
	<str name="id">pantone-cufflink4</str>
	<str name="id">pantone-cufflink7</str>
	<str name="id">pantone-cufflink5</str>
	<str name="id">pantone-cl-cherry</str>
	<str name="id">pantone-cl-jet</str>

Expected result:
A SolrObject full of delicious data instead of an Error and an 
exception would be nice :)

Actual result:
As above, failure to unserialize occurs when more than one 
MoreLikeThis document is present.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2010-04-13 04:34 UTC] trevor at blubolt dot com
I've tracked this down to the handling of result 
serialization in the response.  The primary result doc count 
was being used for the moreLikeThis results array 
serialization.  I've amended the xpath location and context 
accordingly to retrieve the correct count:

--- solr_functions_helpers.orig	1970-01-01 
10:14:37.000000000 +0100
+++ solr_functions_helpers.c	2010-04-12 
16:47:06.000000000 +0100
@@ -737,7 +737,7 @@
 	xmlAttr *curr_prop = properties;
 	xmlXPathContext *xpathctxt = NULL;
-	const xmlChar *xpath_expression = (xmlChar *) 
+	const xmlChar *xpath_expression = (xmlChar *) 
 	xmlXPathObject *xpathObj = NULL;
 	xmlNodeSet *result = NULL;
 	long int document_count = 0;
@@ -763,6 +763,7 @@
 	xpathctxt = xmlXPathNewContext(node->doc);
+	xpathctxt->node = node;
 	xpathObj = xmlXPathEval(xpath_expression, 
 	result = xpathObj->nodesetval;
 	document_count = result->nodeNr;
 [2010-04-13 09:20 UTC]
Thanks a lot for the tip.

I will will make sure to test out and apply that to the next release.

Thanks for reporting this.
 [2010-04-27 23:14 UTC]
This bug has been fixed in SVN.

In case this was a documentation problem, the fix will show up at the
end of next Sunday (CET) on

In case this was a website problem, the change will show
up on the website in short time.
Thank you for the report, and for helping us make PECL better.

This issue has been resolved in revision  298680

Special thanks to max at blubolt dot com for reporting the issue and submitting the patch.
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Wed Jan 19 21:03:36 2022 UTC