Monday, January 27, 2014

Solr Setup and Index Creation

Keep in mind this is for an older version of Solr and Tomcat so make all necessary modifications to get your versions to work.



SOLR SETUP PROCESS
==================

1) Download and Install Tomcat 7.0 32bit
Download the .EXE installer file and install

The installation process should prompt you for an administrator username and password to configure Tomcat.  If more users need to be added in the future, refer to the config file here:
C:\Program Files\Apache Software Foundation\Tomcat7.0\conf\tomcat-users.xml


2) Run Tomcat as Windows Service
Control Panel > System and Security > Administrative Tools > Services

Make sure "Apache Tomcat 7" is running. Set it to start automatically (Properties -> Startup type: Automatic)


3) Download Solr
Download version 3.5.0
Unzip files to any location

From this unzipped folder, copy everything from
\example\solr\
to:
C:\solr\

This is where all the configuration and index files will reside

Also check that Java 1.6 or greater is already installed.

4) Install Solr
Look at the unzipped folder from above step.  Locate file:
apache-solr*.war
and copy into the Tomcat webapps folder:
C:\Program Files\Apache Software Foundation\Tomcat 7.0\webapps\
Rename file to solr.war
If Tomcat Windows Service is running, then folder solr will be created automatically

5) Configure Solr to run on Tomcat
Start -> All Programs > Apache Tomcat 7.0 > Configure Tomcat (Right-click, run as administrator)
Hightlight Java tab
Add "-Dsolr.solr.home=C:\solr" to Java Options
This tells Tomcat where to find config files for Solr

6) Edit Solr config properties to use DataImport for SQL Server
Edit C:\solr\solrconfig.xml
Add new request handler:

----------- 
<!-- DataImporter -->
  <requestHandler name="/dataimport" class="org.apache.solr.handler.dataimport.DataImportHandler">
    <lst name="defaults">
      <str name="config">data-config.xml</str>
    </lst>
  </requestHandler>
------------

Create new file "data-config.xml" in the same folder

Datasource type is jdbcdatasource
Driver is com.microsoft.sqlserver.jdbc.SQLServerDriver
Url format is jdbc:sqlserver://jhopkins;databaseName=jhucc

Also check to make sure the dataimport jar file(s) are in Tomcat:
C:\Program Files\Apache Software Foundation\Tomcat 7.0\webapps\solr\WEB-INF\lib\apache-solr-dataimporthandler*.jar

If not, copy them there and get them from the zip file in the dist folder

7) Install SQL Server JDBC driver

Run the downloaded installer and you will be prompted to unzip the files to a location. 
Unzip to any location.

In the unzipped folder look for \sqljdbc_3.0\enu\sqljdbc4.jar and copy to:

c:\Program files\Apache Software Foundation\Tomcat 7.0\lib\

8) Use pre-made config files.  These include index schema definitions.
Get config files from website solution:
\solr\3.5.0\conf\
and drop into C:\solr\conf\


At this point Tomcat and Solr should be set up:

Verify by browsing to http://localhost:8080/solr (or whichever port you designated upon installation) and see a welcome message and a link to admin

If dataimport is set up correctly with queries used to import data for indexes, browsing to http://localhost:8080/solr/admin/dataimport.jsp should also work without errors




INDEX CREATION AND AUTOMATION SETUP PROCESS
===========================================

1) Copy the cURL .EXE from the website solution:
\lib\curl\

into:
C:\curl\

2) Create a Windows Scheduled Task that runs every 15 minutes and have it start the application:




No comments:

Post a Comment