Wednesday, October 17, 2012

Setting up and playing with Apache Solr on Tomcat

A while back a had a little time to play with Solr, and was instantly blown away by the performance we could achieve on some of our bigger datasets.
Here is some of my initial setup and configuration learnings to maybe help someone get it up and running a little faster.
Starting with setting both up on windows.

Download and extract Apache Tomcat and Solr and copy into your working folders.
Tomcat Setup
If you want tomcat as a service install it using the following:
bin\service.bat install 
Edit the tomcat users under conf.:

If you are going to query Solr using international characters (>127) using HTTP-GET, you must configure Tomcat to conform to the URI standard by accepting percent-encoded UTF-8. Add: URIEncoding="UTF-8"
to the conf/server.xml

Copy the contents of the example\solr your solr home directory D:\Java\apache-solr-3.6.0\home
create the code fragment on $CATALINA_HOME/conf/Catalina/localhost/solr.xml pointing to your solr home.

Startup tomcat, login, deploy the solr.war. Solr Setup
It should be available at http://localhost:8080/solr/admin/ To create a quick test using SolrJ the creates and reads data: Grab the following Maven Libs: JUnit test: Adding data directly from the DB Firstly you need to add the relevant DB libs to the add classpath. Then create data-config.xml as below, if you require custom fields, those can be specified under the fieldstag in the schema.xml shown below the dataconfig.xml A custom field in the schema.xml: Add in the solrconfig.xml make sure to point the the data-config.xml, the handler has to be registered in the solrconfig.xml as follows. Once that is all setup a full import can be done with the following: http://localhost:8080/solr/admin/dataimport?command=full-import Then you should be good to go with some lightning fast data retrieval.

2 comments:

  1. It's excellent to your publish with example which is very useful to me and i got more concept in my web page.

    ReplyDelete

Popular Posts

Followers