Apache Solr 4.0 with Apache Tomcat 7 in Windows 7

If you want to configure Solr4.0.0 in Linux environment please click here.
In this blog i will tell you how to integrate Solr4.0 with apache-tomcat 7 in Windows environment. Before we start i recommend you to read an Introduction of solr4.0 from here.

Pre Requirements
1 - Machine with Windows OS (Windows 7,8,Xp.. ..etc)
2 - Java 6 or Above
3 - Solr 4.0.0 or Above
4 - Apache-tomcat 7 or Above.

Steps to get Solr up on Tomcat Server
  • Install Tomcat on your machine and make sure it is ready to start.
  • Install Solr4.0 distribution package apache-solr-4.0.0.zip and unzip it in your local directory like C:\apache-solr-4.0.0.
  • Make a folder with name solr-home in your local machine like C:\solr-home.
  • Go back to the solr distribution package that you downloaded C:\apache-solr-4.0.0. Have a peek inside the Examples folder. Copy all those files into the C:\solr-home folder.
  • Look into C:\solr-home\solr and you will see two folders with name collection1 and bin, copy these two folders a step up to C:\solr-home.
  • Look into C:\apache-solr-4.0.0\contrib\extraction in downloaded solr package and you will get a lib folder here , copy this folder to C:\solr-home.
  • Go to C:\apache-solr-4.0.0\dist and copy apache-solr-dataimporthandler-extras-4.0.0.jar, apache-solr-dataimporthandler-4.0.0.jar and apache-solr-cell-4.0.0.jar to C:\solr-home\lib
  • Create a file with name data-conf.xml  in C:\solr-home\collection1\conf and add your database details to it like

   <dataSource type="JdbcDataSource" driver="com.mysql.jdbc.Driver" url="jdbc:mysql://localhost:3306/javaguysDB" user="root" password="root" batchSize="1" />
   <document name="emp">
      <entity name="emp_details" query="SELECT * FROM emp_details">
         <field column="id" name="id" />
         <field column="name" name="name" />
         <field column="address" name="address" />
         <field column="details" name="details" />

  • Add this file entry to C:\solr-home\collection1\conf\solr-config.xml file like</requestHandler>
      	<requestHandler name="/dataimport" class="org.apache.solr.handler.dataimport.DataImportHandler">
   <lst name="defaults">
      <str name="config">data-config.xml</str>

  • Copy apache-solr-4.0.war from C:\apache-solr-4.0.0\dist directory to webapps directory inside Tomcat.
  • Start your Tomcat and check webapps directory having one new directory added with name solr.
  • Look inside C:\apache-tomcat-6.0.36\webapps\solr\WEB-INF and open web.xml in a text editor, now look for an entry like this

      	<!-- <env-entry><env-entry-name>solr/home</env-entry-name><env-entry-value> /Path/To/My/solr/Home/solr/</env-entry-value><env-entry-type>java.lang.String</env-entry-type></env-entry> -->

uncomment the entry and add your solr-home path C:\solr-home to /home/javaguys/solr-home/collection1/confsolr-config.xml file under <config> tag.
  • Add your new libraries location to C:\solr-home\collection1\conf\solr-config.xml.  just under <config>  tag like <lib dir="C:\solr-home\lib" />.
And you are all done with it , start your server to localhost:8080/solr and you will get your solr admin panel up.

In upcoming blogs we will see how to make queries to solr server and other important stuff with solr 4.0.0.