- On March 31, 2015
Steps to get Solr running on Jboss
- You should have solr downloaded and extracted, a folder called “solr-4.7.1”
- Make a new folder called “solr”
- Copy all the files from “solr-4.7.1/example” to the new folder called “solr”
- Look into “solr\solr” and you will see two folders with name collection1 and bin, copy these two folders a step up to “solr”.
- Go to solr-“4.7.1\dist” and copy apache-solr-dataimporthandler-extras-4.0.0.jar, apache-solr-dataimporthandler-4.0.0.jar and apache-solr-cell-4.0.0.jar to “solr \lib”. You should also put the jdbc driver in this folder.
- Put the following in solrconfig.xml (for linux only)
- Create a file with name data-conf.xml in solr\collection1\conf and add your database details to it (or just put the file we made)
- Now you need to run apache-solr-4.7.1.war from “solr-4.7.1/dist” on jboss. Rename it first to solr.war then use the admin console to deploy it. Deploy and make sure that it is enabled in the Jboss admin console (under deployment->manage deployment)
- Copy the folder you made called “solr” (where you copied all the stuff) to JBOSSHOME/BIN
- Restart the server and check that the Solr admin console is working on the url http://localhost:8080/solr/
To configure Solr for indexing and searching you need to edit 3 files, all located in JBOSSHOME/bin/solr/collection1/conf.
The files are
- xml – this is an application wide configuration file, what you need to add is the following
<requestHandler name=”/dataimport” class=”org.apache.solr.handler.dataimport.DataImportHandler”>
- data-config.xml – this is used to configure DB access, the following is an example using MSSQL 2008 and a table called Users
<dataSource type=”JdbcDataSource” driver=”com.microsoft.sqlserver.jdbc.SQLServerDriver” url=”jdbc:sqlserver://localhost:1433;databaseName=testDB” user=”sa” password=”123456″ batchSize=”1″ />
<entity name=”Users” query=”SELECT * FROM Users”>
- XML – this file contains configuration files to indexing and querying, it also contains data types and the filters that are implemented on them. We should add the schema for the tables that we want indexed here.
The following is a small example used on a sample Users DB
<!–my schema data –>
<field name=”first” type=”text_general” indexed=”true” stored=”true”/>
<field name=”last” type=”text_general” indexed=”true” stored=”true”/>
<field name=”age” type=”int” indexed=”true” stored=”true”/>
<field name=”image” type=”text_general” indexed=”true” stored=”true”/>
Note that the filters are added on the field type not the field. Think of it as classes that use a basic primitive data type and add to it a set of filters.