Search This Blog

Showing posts with label Solr. Show all posts
Showing posts with label Solr. Show all posts

Thursday, October 13, 2011

Solr 3.x and Tomcat setup tutorial

There is a good tutorial on solr's official site on Solr with jetty but I wouldn't find a good instruction on Solr with Tomat setup thats clean and easy. So here is my instruction.

1. download solr ( we are at version 3.x.x)
2. extra files    (tar -zxvf apache.solr.blabla.tar)
3. create solrHome folder
4. go to the upzipped solr directory and copy dist/apache.solr.3.x.x.war to solrHome
5. rename that file in solrHome from apache.solr.3.x.x.war to solr.war
6. download tomcat and modify server.xml as in 7
7.       <Host name="localhost"  appBase="webapps"
            unpackWARs="true" autoDeploy="true"
            xmlValidation="false" xmlNamespaceAware="false">
                <Context docBase="/home/ec2-user/sandbox/solrHome/solr.war" path="/solr" reloadable="true" unpackWAR="false">
                        <Environment name="solr/home" type="java.lang.String" value="/home/ec2-user/sandbox/solrHome/" override="true" />
                </Context>

      </Host>
8. copy folders and files below  to solrHome folder also make a folder name "data" too.
conf, example, exampledocs, start.jar
these things can be found in the solr distribution tar file downloaded.

9. test solr.
go to http://localhost:8983/solr/admin/
make sure server is up and running.

10. index the monitor data 
-data are in xml format, if we want to add more data, modify the solrconfig and schema.xml files
-to fit the new data format. this is actually very simple.

cd /home/ec2-user/sandbox/solrHome/exampledocs
user:~/solr/example/exampledocs$ java -jar post.jar solr.xml monitor.xml
make sure not error from catalina.out.

11.
http://localhost:8983/solr/browse
check interface. play with it, click it. no error.

12
index all data.
java -jar post.jar *.xml

13
http://localhost:8983/solr/browse
check interface. play with it, click it. no error. more data.

------------------
command to delete all index

java -Ddata=args -Dcommit=no -jar post.jar "<delete><query>*:*</query></delete>"

java -Ddata=args -Dcommit=no -jar post.jar "<commit/>"

java -Ddata=args -Dcommit=no -jar post.jar "<optimize/>"
---------------------