phpnode/YiiSolr — Issue #3: Issue with ASolrDataProvider
Author: utkarshpanwar
Created: 2011-11-25 06:08:13+00:00
State: open

The code below works fine

$criteria=new ASolrCriteria;
$criteria->addCondition("screen_name:hari*");
$criteria->addCondition("sex:m");
$docs = PartnerSolrDocument::model()->findAll($criteria);

Here is the query submitted to solr, message displayed in the solr console as below:-

INFO: [] webapp=/solr path=/select/ params={indent=on&wt=xml&q=(screen_name:hari*)+AND+(sex:m)&version=2.2} hits=1 status=0 QTime=1

But if I use the code below:

$criteria=new ASolrCriteria;
$criteria->addCondition("screen_name:hari*");
$criteria->addCondition("sex:m");
$p = new ASolrDataProvider('PartnerSolrDocument', array('criteria'=>$criteria,));
var_dump($p->getData());

I get the following error;

java.lang.NumberFormatException: For input string: "0q=(screen_name:hari*) AND (sex:m)"
at java.lang.NumberFormatException.forInputString(Unknown Source)

Here is the query being submitted to solr:

INFO: [] webapp=/solr path=/select/ params={indent=on&start=0&q=(screen_name:har
i*)+AND+(sex:m)&wt=xml&version=2.2&rows=0q%3D(screen_name:hari*)+AND+(sex:m)&row
s=10} status=500 QTime=2

Here q is coming two times and that even without & before that.

But if write the code as below, although it works but query being submitted is wrong

$criteria=new ASolrCriteria;
$criteria->addCondition("screen_name:hari*");
$criteria->addCondition("sex:m");

$criteria->setStart(0);
$criteria->setLimit(13);

$p = new ASolrDataProvider('PartnerSolrDocument', array('criteria'=>$criteria,));

var_dump($p->getData());

Outout on solr console, some field are also duplicated. Why rows=10 is coming with rows=13?

INFO: [] webapp=/solr path=/select/ params={indent=on&start=0&start=0&start=0&q=
(screen_name:hari*)+AND+(sex:m)&wt=xml&version=2.2&rows=13&rows=0q%3D(screen_nam
e:hari*)+AND+(sex:m)&rows=13&rows=10} hits=1 status=0 QTime=1