Here is a step-by-step procedure to help.
PART 1: CONFIGURING SOLR WITH TOMCAT
Step 1: Download Solr. This is just a zip file.
Step 2: Copy from your SOLR_HOME_DIR / dist / apache-solr-1.3.0.war to the tomapat webapps directory: $ CATALINA_HOME / webapps / solr.war - Note the change in the name of the military file. It is important.
Step 3: Create your solr home directory in your chosen location. Here is the configuration for this solr installation. The easiest way to do this is to copy the SOLR_HOME_DIR / examples / solr directory anywhere you want your Solr home container to be. Say put it in C: \ solr.
Step 4: We hope you set the environment variables; if not, set JAVA_HOME, JRE_HOME, CATALINA_OPTS, CATALINA_HOME. Note that CATALINA_HOME refers to your Tomcat directory, and CATALINA_OPTS refers to the amount of heap memory that you want to transfer to your Solr.
Step 5: Launch tomcat. Please note that this is only necessary to allow tomcat to unzip your war file. If you look under $ CATALINA_HOME / webapps, there should now be a solr directory.
Step 6: Stop tomcat
Step 7: Go into this solr directory and edit WEB-INF / web.xml. Scroll down until you see a post that looks like this:
Define your Solr home (for example: C: \ solr) and uncomment the env entry.
Step 8: Launch Tomcat again and everything should go great. You must ensure that solr is running by trying the URL http: // localhost: 8080 / solr / admin / .
PART 2: CONFIGURING MALL WITH USER MSSQL USING DATA IMPORT PROCESSING
Step 1: Download the Microsoft SQL Server 3.0 JDBC driver. Just extract the contents. Create a folder under the solr home directory (example: C: \ solr \ lib). Copy the sqljdbc4.jar file from the archive loaded into it.
Step 2. So, in your Solr house you need basic conf and lib directories. The first of them, for example, may be associated with step 3 of part 1, and lib is the directory that you created in step 1 of part 2.
Step 3. Go to the conf directory. Open 3 files in your editor: data-config.xml, schema.xml and solrconfig.xml.
Step 4. Start by editing data-config.xml. Put your SQL query, database name, server name, etc. Example:
• <dataConfig> • <dataSource type="JdbcDataSource" driver="com.microsoft.sqlserver.jdbc.SQLServerDriver" url="jdbc:sqlserver://XYZU:1433;databaseName=myDB" user="test" password="tester" /> • <document> • <entity name="Text" query="select DocumentId, Data from Text"> • <field column="DocumentId" name="DocumentId" /> • <field column="Data" name="Data" /> • </entity> • </document> • </dataConfig>
Step 5: Tell Solr about our data-config.xml file. This can be done by adding a request handler to the solrconfig.xml file, which is the solr configuration file. Add the following request handler to the solrconfig.xml file:
• <requestHandler name="/dataimport" class="org.apache.solr.handler.dataimport.DataImportHandler"> • <lst name="defaults"> • <str name="config">C:\solr\conf\data-config.xml</str> • </lst> • </requestHandler>
Step 6: Configuring schema.xml - In this file you can do several things such as setting the data types of your fields, setting a unique / primary key for your search, etc.
Step 7: Launch Tomcat
Step 8: Now visit http: // localhost: 8080 / solr / admin / dataimport.jsp? Handler = / dataimport and start the full import.
Some handy notes:
• There are a number of reasons a data import could fail, most likely due to problem with the configuration of data-config.xml. To see for sure what going on you'll have to look in C:\tomcat6\logs\catalina.*. • If you happen to find that your import is failing due to system running out of memory, however, there an easy, SQL Server specific fix. Add responseBuffering=adaptive and selectMethod=cursor to the url attribute of the dataSource node in data-config.xml. That stops the JDBC driver from trying to load the entire result set into memory before reads can occur. • Note that by default the index gets created in C:\Tomcat6\bin\solr\data\index. To change this path just edit solrconfig.xml & change <dataDir>${solr.data.dir:./solr/data}</dataDir>. • In new Solr versions, I think 3.0 and above you have to place the 2 data import handler jars in your solr lib directory (ie for example apache-solr-dataimporthandler-3.3.0.jar & apache- solr-dataimporthandler-extras-3.3.0.jar). Search for them in your Solr zip you downloaded. In older Solr versions this is not required because they are bundled with solr.war. Since we have placed the data import handlers in the lib directory so we need to specify their paths in solrconfig.xml. Add this line to solrconfig.xml: (Example: <lib dir="C:/solr/lib/" regex="apache-solr-dataimporthandler- \d.*\.jar" />)