Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Solr integration in CakePHP with solarium client

    • 0
    • 3
    • 4
    • 1
    • 0
    • 0
    • 0
    • 0
    • 1.70k
    Comment on it

    Hi,

    Before using Solr in CakePHP, we need to decide which Solr client we are going to use. After doing lots of search I finalized Solarium which is up to date and easy to use. For Installing Solr, I used following link:

    http://www.shayanderson.com/linux/how-to-install-apache-solr-4-5-on-centos-6-4.htm

    In the above link, you might get problem with "yum install mysql-connector-java", then you can directly download mysql-connector-java and save it in your /root folder and then change the link to:

    ln -s /root/mysql-connector-java-5.1.34/mysql-connector-java-5.1.34-bin.jar /opt/solr/dist/mysql-connector-java.jar (If solr is installed in /opt)

    If you have successfully installed Solr then you need to install Solarium. For this you can use following link:

    http://wiki.solarium-project.org/index.php/V3:Installation#Getting_Solarium

    Install Solarium with Composer is best way. Just install composer and then create a folder /app/vender/solarium in your CakePHP application and create a file composer.json and follow the steps in above link.

    Once you have installed Solr and Solarium then you are ready to use Solr search within your application.

    Before using Solr, we need to clarify our requirement. In my case I have a table of products which have more than 3 Million products in it and I have to implement search with title of products. So first of all we need to add all product's id and title to solr. For this you need to follow these steps to do this:

    Step 1: Open your schema.xml file and check if title and id are already there. These are common and already available in this file. If you need to add some more fields for searching then you can add these fields in this xml file.

    Step 2: Write a code to add product's title and id to solr.For code snipped please use attached file SolrController.php. I have created this file in simple way so that it can be used in core php and other platform as well. You can include your Solarium Vendor in your AppController.php and create a component for these functions.

    This article is only for beginners and for those who have no basic idea for using Solr and have limited time as I had. There is another appropriate way to use Solr is using Datasource. In which we can create a Solr datasource like mysql datasource but I am not familiar with that. So please share if anyone has implement Solr with datasource appoach. Please refer to following post in Stackoverflow for reference: http://stackoverflow.com/questions/27525388/how-to-implement-solr-and-solarium-in-cakephp

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: