solr Solr component

  1. Documentation
  2. Change Log

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.
7 0
13 followers
1 449 downloads
Yii Version: 1.1
License: BSD-2-Clause
Category: Web Service
Tags:
Developed by: chahedous
Created on: Jul 2, 2010
Last updated: 13 years ago

Downloads

show all