Yii 1.1: yii-solr

A solr extension to allow fast and easy full text searching with Yii

YiiSolr is a Yii extension that provides a wrapper for the pecl solr library (http://www.php.net/manual/en/book.solr.php) to make fast searching with Yii really easy. The wrapper allows the use of familiar Yii constructs such as models, data providers etc with a solr index.


Tested with Yii 1.18 but should work with any recent version


Please see the github page for usage examples


Total 8 comments

#9433 report it
phpnode at 2012/08/10 04:13am
Re: Will this work with a remote Solr instance?

A. Yes, configure the host settings for the connection in your main config.

#9429 report it
M Wotton at 2012/08/09 11:52pm
Remote Solr server

Will this work with a remote Solr instance? I am assuming I can just specify an alternative host in the config, but I want to make sure before I hassle my webhost to install the PECL Solr package.


#8206 report it
deanf7 at 2012/05/17 02:01pm
Adding fields

Addenum: For any others new to Solr you need to add your custom fields in the solr config/schema.xml file. Then everything should work fine.

Has anyone figured out the adding new fields to a document for indexing? This will blow up with the error: ERROR: [doc=1] unknown field 'creator'.

$ia_doc = new ASolrDocument();
$ia_doc->id = $doc['id'];
$ia_doc->name = $doc['Title'];
$ia_doc->creator = $doc['Creator'];

ASolrDocument::setAttributes() and ASolrDocument::add() also return this error.



#7882 report it
phpnode at 2012/04/24 02:16pm
ASolrCriteria extends SolrQuery which in turn extends SolrParams

So you can just do


#7880 report it
blindMoe at 2012/04/24 02:14pm
Accessing SolrParams


How would I incorporate SolrParams class so I can add individual params like:

SolrParams::addParam('q.op', 'OR');

Thanks in advance

#7809 report it
Yureshwar Ravuri at 2012/04/19 09:37am
How to add fields & also it fetches only 10 records


How can add fields. It is not accepting any other name for example

$doc = new ASolrDocument;
$doc->id = 123;
$doc->name = "test document";
$doc->city = "";



It fetches only 10 records even if i using findAll($criteria); If i manually search from solr it fetches more than 10 records. Can you please tell me how to fetch all records.

I have modified the function query in ASolrDocument to fetch all the records.

if(!$all) {
} else {
#7804 report it
phpnode at 2012/04/19 06:48am
Import the extension

You have to import the extension components, so in your config/main.php:

'import' => array('packages.solr.*')

For the tests to work, you must have SQLite installed as well as the example index that comes with Solr. I will try and improve this in future to make it easier to run the tests

#7803 report it
Yureshwar Ravuri at 2012/04/19 06:40am
Unable to use this extension

Could you please eloborate more on how to set up.

I have configured the aliases path and solr component. And also i have started the solr. I have indexed my database using solr. Now i want to use this extension to fetch the records. But initial set up was problem. When i do the phpunit test as mentioned it throws me below mentioned 6errors.

Time: 4 seconds, Memory: 23.50Mb
There were 6 errors:
1) ASolrConnectionTest::testClientOptions
InvalidArgumentException: You must not expect the generic exception class.
2) ASolrSearchableTest::testBasics
CDbException: CDbConnection failed to open the DB connection.
3) ASolrSearchableTest::testGetIsModified
Trying to get property of non-object
4) ASolrSearchableTest::testFind
Trying to get property of non-object
5) ASolrSearchableTest::testDelete
Trying to get property of non-object
6) ASolrSearchableTest::testPopulateFromSolr
Trying to get property of non-object
Tests: 26, Assertions: 2824, Errors: 6.

And after adding the configuration to the config file. and i use the following code in my controller it shows an error


$criteria = new ASolrCriteria;
$criteria->query = "name:test"; // lucene query syntax
$docs = ASolrDocument::model()->findAll($criteria);


include(ASolrCriteria.php): failed to open stream: No such file or directory

Thanks in advance.

Leave a comment

Please to leave your comment.

Create extension
No downloadable files yet