Yii Framework Forum: Yii Solr Problems On Clistview - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Yii Solr Problems On Clistview How to use filter Query (fq) ind yii-solr Rate Topic: -----

#1 User is offline   rall0r 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 181
  • Joined: 11-November 10
  • Location:Bln

Posted 04 December 2012 - 07:48 AM

Hi,

I use the yii-solr extension to handle solr search with yii and models.
My solr results are renderd insight an CListView Element.
The yii solr model runs with an additional Parameter:
$configDataProvder["criteria"]->addParam('fq','parent_id:bd2a');


The CListView `ajaxUpdate` option is enabled `ajaxUpdate=true`
The initial CListView listing works fine.

If I use pagination (if i change the page), CListView fails and returns an Solr 400 Error (bad request).

Looking at the solr log: i see, that my additional parameter is set in the solr url, BUT it's empty
http://my.host:8080/solr/....&fq=parent_id:&start=30 ......


So the question is: why the additional Parameter is empty?
And 2nd Question: is there an better way to use fq parameter than the "addParm" feature, which I use?

Thank you, rall0r
0

#2 User is offline   rall0r 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 181
  • Joined: 11-November 10
  • Location:Bln

Posted 04 December 2012 - 09:44 AM

To answer my own question - maybe someone has the same issue.

The problem is not an Yii Solr problem.
The point is, that the CListView update URL used an specific parameter (ID):
http://.....index.php/controller/action/id/bd2a

As you can see, i use an URL rule to rewrite the url to change from
http://.....index.php?r=controller/action&id=bd2a

to
http://.....index.php/controller/action/id/bd2a


This feature is provided by Yii, if you uncomment the following lines at the config/main.php
		'urlManager'=>array(
			'urlFormat'=>'path',
			'rules'=>array(
				'<controller:\w+>/<id:\d+>'=>'<controller>/view',
				'<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',
				'<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
			),
		),


As you can see: there is an rewrite rule for "id" as a part of the url.
It looks like, "id" is an reserved GET-Parameter in Yii.

Because I doesn't know that, I used the id parameter for my application. Because of that URL Mangaer rule, the, URLs where generated like this:
http://.....index.php/controller/action/bd2a

...as you can see: the "id" was removed.
This war the reason, why CListView and Yii Solr does not work correctly.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users