Arun Chinnachamy bio photo

Arun Chinnachamy

I am a chemical Engineer from BITS-Pilani. Right now, I work as Technology Lead at MySmartPrice. This is just a place where I write about the things I work and think.

Email Twitter Facebook Github

Solr, the enterprise search platform built over Apache Lucene project is a stunning indexing engine with capabilities like full text search, faceted search, hit highlighting and caching capabilities. It is written in Java and very powerful with less memory print. If you are looking forward to find what solr is, the solr project page is the right place to start.

Recently, I have been looking into how to use solr for our search functionality. Initially, we were hesitant to use Solr as we were afraid we lack java knowledge. But You can perform all supported functionalities through the REST-like API. Now it is time to explain how to install and configure solr. so here is the Solr Installation guide.

Solr Installation:

I will explain how to install Tomcat6 and Solr in Debian or Ubuntu.  In order to install Tomcat6, Run the following command in terminal. It is assumed you are installing in localhost, if not, replace the url with IP Address.

sudo apt-get install tomcat6 tomcat6-admin

To confirm Tomcat6 installation, Open

http://localhost:8080

Get and Install the latest stable version of solr,

wget http://apache.cict.fr/lucene/solr/3.6.0/apache-solr-3.6.0.tgz
tar xvfz apache-solr-3.6.0.tgz
cd apache-solr-3.6.0
cp dist/apache-solr-3.6.0.war /var/lib/tomcat6/webapps/solr.war
cp -fr example/solr /var/lib/tomcat6/
chown -R tomcat6:tomcat6 /var/lib/tomcat6/solr

Now restart the Tomcat to load the Solr Application.

 sudo /etc/init.d/tomcat6 restart

You have successfully installed and running the example application came in the package. You can check whether it is working or not, open

http://localhost:8080/solr

. Now you should see the Solr Welcome page. This is just the example application. Now lets configure the installation to have two cores.

Configuration of Solr Cores:

Now that the installation of SOLR is complete, Lets see how you can configure multiple cores in same installation. Each core will have its own configuration and indexes. In order to create cores, edit

/var/lib/tomcat6/solr/solr.xml

The following text will create two cores named core1 and core2 in the same solr installation. Make a copy of the Solr example directory as a template for your project which makes it easy to start with.

<solr persistent="false">
 <cores adminPath="/admin/cores" defaultCoreName="core1">
     <core name="core1" instanceDir="core1" />
     <core name="core2" instanceDir="core2" />
 </cores> 
</solr>

The core1 and core2 are the respective directories where the configuration files and indexes will be searched. To simplify the configuration, Copy the directories (bin conf data lib) in

/var/lib/tomcat6/solr/

in to the core1 and core2. So now the core1 and core2 exactly the same configuration.

if you go to

http://localhost:8080/solr

the page will present you with options to select the core to use. Now the installation of SOLR and setting up the cores is done but still the data needs to be imported and indexed to use the functions. For more information about the cores, visit Core Admin page.

Look forward for my other posts on how to configure a core and also on how to import data from MySQL to SOLR.

UPDATE: If you are looking for importing MySQL Tables into SOLR index, have a look into my other post on SOLR MySQL Data Import.

UPDATE: If you are looking for SOLR Tutorials and other topics related to SOLR, Visit SOLR Tutorials at InstallationPage.com