This extension is Yii version of Solr-client-Php. It uses Solr-client-Php to communicate with the Solr server
protected/extensionsAdd to protected/config/main.php // autoloading model and component classes
'import'=>array( 'application.models.*', 'application.components.*', 'application.extensions.solr.*', ) 'components'=>array( 'userSearch'=>array( 'class'=>'CSolrComponent', 'host'=>'localhost', 'port'=>8080, 'indexPath'=>'/solr/user' ), 'commentSearch'=>array( 'class'=>'CSolrComponent', 'host'=>'localhost', 'port'=>8080, 'indexPath'=>'/solr/comment' ),
See the following code example:
//To add or update an entry in your index Yii::app()->commentSearch->updateOne(array('id'=>1, 'name'=>'tom', 'age'=>22) ); //To add or update many documents Yii::app()->userSearch->updateMany(array('1'=>array('id'=>1, 'name'=>'tom', 'age'=> 25), '2'=>array('id'=>2, 'name'=>'pitt') ); //To search in your index $result= Yii::app()->userSearch->get('name:tom',0,20); echo "Results number is ".$result->response->numFound; foreach($result->response->docs as $doc){ echo "{$doc->name} <br>"; }
See http://code.google.com/p/solr-php-client/ for more functions
Total 4 comments
Thx very much for sharing this extension.
Since the source code is no longer updated for a long time.
We could apply the latest version of Solr-Client-PHP by self:
Just get the latest version and extract the release file under "phpSolrClient".
Hi, I'm very happy with this extension. But I encountered a bug in the 'get' method.
the following condition doesn't work when using grouped fields
if ( $response->response->numFound > 0 ) { return($response); }
I've removed this check and now everything works
Line 65 in the initial release lacks a ; at the end of the line.
Thx. But it will be a good idea if you create a criteria for search
Leave a comment
Please login to leave your comment.