Showing posts with label Java. Show all posts
Showing posts with label Java. Show all posts

Sunday, June 3, 2012

Installing Apache Solr on Windows with Tomcat

1) JDK


Install java development kit  preferably version 1.6 or greater.

2)Tomcat


As a complete web dev environment for windows i recommend using XAMPP. It comes with built in Tomcat servlet, so you won't have to waste your time installing tomcat. Well regarding version of tomcat, i have successfully tested solr on tomcat 5,6 and 7.
     Tomcat can be managed from xampp control panel or you can install it as a windows service so that it can be run independently from xampp. Well doesn't matter much whether it is xampp service or a windows service. To install it as a windows service run the 'service' batch file in c:\xampp\tomcat\bin .
     After installation to check if tomcat is running open you browser and ping
     localhost:8080



Xampp download

3) Solr install


Download the latest solr release which is currently solr 3.6. Download the tarball from here and extract it to say  downloads\apache-solr-3.6.0

a) Preparing solr home directory

  1. Make a new directory in C:\ and name it solr.
  2. Copy dist and contrib directories from downloads\apache-solr-3.6.0 i.e. downloads\apache-solr-3.6.0\dist and downloads\apache-solr-3.6.0\contrib to C:\solr\dist and C:\solr\contrib
  3. Make a directory named solr inside C:\solr and copy  downloads\apache-solr-3.6.0\example directory contents to it. Now C:\solr\solr is what is called solr home.

b) Configuring tomcat to detect solr

  1. Copy  downloads\apache-solr-3.6.0\dist\apache-solr-3.6.0.war file to C:\xampp\tomcat\webapps directory and rename it to solr. If tomcat service is on you will find that a solr directory is automatically created. If tomcat is off don't bother it would be created next time tomcat starts.


2.    Now run C:\xampp\tomcat\bin\tomcat7w.exe (7 is for the version), select java tab and in java options pane write -Dsolr.solr.home=C:\solr\solr . Click OK and configuration is done. Restart tomcat.



c) Test solr

In your browser enter localhost:8080/solr/admin and you will see.





That's it. Solr is installed and now it can be used to do fast searching on huge amount of data from any source be it a sql database or a file. But to do that a lot of work still needs to be done related to request handlers and schemas. In the future posts i will be talking about the internals of solr.


Note : If you get errors like no cores were created or unable to load class java.* error, that simply means that you made mistake in either providing solr home path correctly in tomcat7w.exe or you forgot to copy dist and contrib folders to c:\solr.

 Post your queries if you have issues installing solr.



Thursday, May 17, 2012

Intro to Solr

Apache Solr based on Lucene is one of the best open source enterprise search platforms available for building and awesome custom search engine for sites as big as wikipedia. It can be used  with any web frameworks such as CodeIgniter, Wordpress, Drupal, Joomla etc. and offers full customization according to the needs of  the website. Sites that currently use it include whitehouse.gov, netflix, sourcefourge, cnet, digg and many more.


SOLR vs Google's Custom search ?

Google's custom search is awesome undoubtedly, but if you are building a search engine for a company then you cannot just simply handover your database to Google for analysis. Here comes the solr, an open source platform which lets you customize everything and build a search engine as good as google's custom site search providing full privacy to your database.


Solr Features :
  • Full-Text Search Capabilities
  • Highly scalable
  • Blazing Fast and optimized for high web traffic
  • Supports multiple instances and cores
  • XML, JSON and HTTP interfaces for request and response
  • Built in Spell checking, Faceting, Geo-spatial search and Highlighting configurations


Requirements :
  • A Java servlet such as Apache Tomcat or Jetty
  • Java Runtime Environment preferably version 1.5 onwards

About Servers :

Localhost Shared Server Virtual Private Server Dedicated Server
Can be run Can't be run Can be run Can be run

Nothing fancy about it, you simply need root access to install and configure java servlet like tomcat and also installing it as a service requires root privileges. Shared servers do not offer these facilities.


In this blog, i will share the complete know-how on building a search based on Apache solr right from square one. I would post exact codes, configuration and full info related to the same in the coming days. Keep following.....




Next : Installing Solr