Search This Blog

Sunday, September 29, 2013

Apache Solr Installation and Configuration


Installation

1. Download Apache Solr Package (http://www.apache.org/dyn/closer.cgi/lucene/solr/)

2. In shell enter “tar –xvzf apache-solr-x.x.x.tgz” this step will create a folder apache-solr-x.x.x

3. Rename the folder for ease of use “mv apache-solr-x.x.x apache-solr”

4. Install JDK (requires > 1.6.0) can download from sun downloads(http://java.sun.com/javase/downloads/widget/jdk6.jsp)

5. “cd apache-solr/example/”

6. Start the servlet “Java –jar start.jar”, Long list of messages will appear at the end you can see message as follows : INFO: Started SocketConnector @ 0.0.0.0:8983

7. Check for errors in java if so please correct it and restart the server. To Stop the server use “CTRL+C”

8. If everything goes fine you should see a screen as below in your browser



Configuring with MySQL Database

1. Download jdbc driver for mysql (mysql-connector-java-5.1.12-bin.jar) put it in the “lib” folder , this is the one which is responsible for communication between MySQL db and apache Solr

2. Open data-config.xml in your conf folder under example directory (example->conf->data-config.xml) in any text editor

3. Add XML as below



4. Data source is the tag which holds the data about the connecter (which database ,user, password, url, driver etc.,), we can have many data source in a single file and use the name of data source to connect

5. Change the “Query” in the “entity” tag as you want to create index it can also use joins and db functions in it

6. There is another set of tags called “Field” which used to specify what are the column which are returned by the query is going to be used (take care in giving values to name attribute),”Column” attribute is used to map the column name to the name attribute

7. Open “schema.xml” in the same folder search for “fields” tag and remove the content of it and add your columns names as picture below

No comments:

Post a Comment