This extension is Yii version of Solr-client-Php. It uses Solr-client-Php to communicate with the Solr server
Resources ¶
Documentation ¶
Requirements ¶
- Yii 1.0 or above
Installation ¶
- Extract the release file under
protected/extensions
Add 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'
),
Usage ¶
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
Change Log ¶
July 2, 2010 ¶
- Initial release.
Small bug
Line 65 in the initial release lacks a ; at the end of the line.
Simple but great!
Thx. But it will be a good idea if you create a criteria for search
Another bug
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
Good simple example
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".
If you have any questions, please ask in the forum instead.
Signup or Login in order to comment.