Subject: | WebService::Solr::Response::docs method fails on parsing query that used grouping |
Date: | Wed, 11 Jan 2012 15:35:48 +0200 |
To: | bug-WebService-Solr [...] rt.cpan.org |
From: | Mishanya Goltsman <michael.goltsman [...] gmail.com> |
Hi,
I send the query to Solr using WebService::Solr::Query with option
group=true and group.field=XXX.
Then I try to get documents from response using ->docs method and get next
error:
Attribute (docs) does not pass the type constraint because: Validation
failed for 'ArrayRef' with value undef at /.....
The problem is in response structure that differs hard between regular
query and query using grouping:
regular query:
'_content' => '
{
"responseHeader":
{
"status":0,"QTime":1,
"params":
{"sort":"SCRIPT desc, USA_SORT_TITLE asc, CJK_SORT_TITLE_1
asc","fl":"OBJECT_ID","wt":"json","q":" OBJECT_ID:* AND
TITLES_NORMALIZED:EVOLUC* AND (+SCRIPT:Latin) "}
},
"response":
{
"numFound":18,"start":0,
"docs":[{"OBJECT_ID":"1000000000373148"},{"OBJECT_ID":"1000000000373149"},{"OBJECT_ID":"1000000000373150"},{"OBJECT_ID":"1000000000373151"},{"OBJECT_ID":"1000000000374693"},{"OBJECT_ID":"1000000000373152"},{"OBJECT_ID":"1000000000373153"},{"OBJECT_ID":"1000000000373154"},{"OBJECT_ID":"1000000000373155"},{"OBJECT_ID":"1000000000373156"}]
}
}',
group query:
'_content' => '
{
"responseHeader":
{
"status":0,"QTime":1,
"params":
{"sort":"SCRIPT desc, USA_SORT_TITLE asc, CJK_SORT_TITLE_1
asc","fl":"OBJECT_ID","wt":"json","q":" OBJECT_ID:* AND
TITLES_NORMALIZED:EVOLUC* AND (+SCRIPT:Latin) "}
},
"grouped":
{
"OBJECT_ID":
{
"matches":18,
"groups":
[
{
"groupValue":"1000000000373148",
"doclist":
{
"numFound":1,
"start":0,
"docs":
[{"OBJECT_ID":"1000000000373148"}]}},{"groupValue":"1000000000373149","doclist":{"numFound":1,"start":0,"docs":[{"OBJECT_ID":"1000000000373149"}]}},{"groupValue":"1000000000373150","doclist":{"numFound":1,"start":0,"docs":[{"OBJECT_ID":"1000000000373150"}]}},{"groupValue":"1000000000373151","doclist":{"numFound":1,"start":0,"docs":[{"OBJECT_ID":"1000000000373151"}]}},{"groupValue":"1000000000374693","doclist":{"numFound":1,"start":0,"docs":[{"OBJECT_ID":"1000000000374693"}]}},{"groupValue":"1000000000373152","doclist":{"numFound":1,"start":0,"docs":[{"OBJECT_ID":"1000000000373152"}]}},{"groupValue":"1000000000373153","doclist":{"numFound":1,"start":0,"docs":[{"OBJECT_ID":"1000000000373153"}]}},{"groupValue":"1000000000373154","doclist":{"numFound":1,"start":0,"docs":[{"OBJECT_ID":"1000000000373154"}]}},{"groupValue":"1000000000373155","doclist":{"numFound":1,"start":0,"docs":[{"OBJECT_ID":"1000000000373155"}]}},{"groupValue":"1000000000373156","doclist":{"numFound":1,"start":0,"docs":[{"OBJECT_ID":"1000000000373156"}]}}]}}}',
It looks like you should think how you want to parse and store grouped
result,
Thank you
Goltsman Michael