Friday, August 24, 2012

Solr with Apache on Windows 7 and Windows Server 2008 R2

Download Apache7 Windows Service installer from the below location:
Install as a service by executing the exe
Download solr and unzip it on to disk
unzip it apache-solr-3.6.1
create c:\web\  and copy folder apache-solr-3.6.1\example to c:\web\
rename apache-solr-3.6.1\apache-solr-3.6.1\dist\apache-solr-3.6.1.war to solr.war
Now copy solr.war to C:\Program Files (x86)\Apache Software Foundation\Tomcat 7.0\webapps\
Now create solr.xml file n C:\Program Files(x86)\Apache Software Foundation\Tomcat 7.0\conf\Catalina\localhost\
For Single Core:
Add the below content in solr.xml:
<?xml version="1.0" encoding="UTF-8"?>
<Context docBase="C:\Program Files(x86)\Apache Software Foundation\Tomcat 7.0\webapps\solr.war" debug="0" crossContext="true" >
    <Environment name="solr/home" type="java.lang.String" value="C:\web\example\solr" override="true" />
</Context>

Restart Apache and the single core will run
Note: DocBase and Solr/Home path should match your system drive and path
For Multicore:
add the below content in solr.xml:
<?xml version="1.0" encoding="UTF-8"?>
<Context docBase="C:\Program Files(x86)\Apache Software Foundation\Tomcat 7.0\webapps\solr.war" debug="0" crossContext="true" >
    <Environment name="solr/home" type="java.lang.String" value="C:\web\example\multicore" override="true" />
</Context>

By default it has two core but if you want to add one or many core then make copy of one core and rename it (say core2) then add the core name to the  C:\web\example\multicore\solr.xml add the below line for new core
<cores adminPath="/admin/cores">
    <core name="core0" instanceDir="core0" />
    <core name="core1" instanceDir="core1" />
    <core name="core2" instanceDir="core2" />
  
Restart Apache and you will get solr running with multiple core.