Search Engine For Electronic Commerce With Yii

Hi there!

First post on your forum. I would like to thank the community as I spent hours reading this forum and each time I found a solution to my problems :)

This time I need your help concerning a decision I should take concerning search engine. In past projects I used Lucene extension and I managed to put it in production. Results are good but it’s very simple and my website has a low trafic.

Now I’ve built a team and we are working on a new project of electronic commerce built on Yii (Yes we can!). One big part will be to handle clients high requests on our products and we need a strong search engine that could handle massive clients query.

After a google search I found the Apache SOLR project. It seems to be fit to high request volumes but when I check the extension done in Yii I feel like it doesn’t really fetch with Active Records. In fact it seems that if I do a $object->save() it will save in my SQL database but I also need to write my data in SOLR so it’s like keeping two databases updated at a time.

My questions are:

  • is SOLR a solution for my query? if not is there something to handle/create a strong search module in Yii?

  • do I really need to have two database (I consider a lucene index as a database) or is there a way to abstract this part and use AR directly?

  • do you know what kind of search tools major compagny like Amazon are using to have such performance?

Thanks for your help! :)

hi, I’m using Yii with solr, it’s good search engine. Solr index your data in solr location (in ram), so when your data change, you have to reindex changed data to solr, but it’s very fast -> it ok! (sory because my english :D)

Hi!

Thanks for your reply :). Ok and how did you manage to update data? Each time you make a db update you also update your SOLR index or you have a “global update” function that exports all data to your SOLR index?

I think that I will write new function that saves my data both in SQL and in SOLR but maybe someone already did it…

Hi, have you considered elasticsearch?

You will install the daemon on your server and it will offer you an API interface to update your search indexes.

There are clients(php classes) like ElasticaSearch that you can use in php to communicate with your elasticsearch daemon, that is to index, search, delete, etc.

Using with Yii is very simple, you can hook into the afterSave() event of CActiveRecord to send your record to be indexed in elasticsearch, same you can hook into afterDelete() to remove an indexed record from elasticsearch thus removing the need to have a cron job running to index your records.

I have used it in a huge search driven application with extraordinary results :)

Give it a try, you will love it.

Hi, you can use afterSave(), afterDelete() event in Yii to update your data to Solr. To connect to Solr, I use solr extension(http://www.yiiframework.com/extension/solr). If you want to make sure, you can run cronjob to update all your data to solr everyday :D