Recently, I am working on a search engine project. The following is a simple record of the main steps for integrating solr3.6 with Tomcat:
Download the apache-solr-3.6.0 (for the http://lucene.apache.org/solr/downloads.html), decompress it, get the apache-solr-3.6.0, and I put it in E: \ Software \ lucene-3.6.0 \ apache-solr-3.6.0
1. copy the files under E: \ Software \ lucene-3.6.0 \ apache-solr-3.6.0 \ example \ SOLR to the location of the server (for example, D: \ Lucene \ SOLR \ home ), you can delete data in the data directory and keep the data folder;
2. Copy the SOLR. War Program in E: \ Software \ lucene-3.6.0 \ apache-solr-3.6.0 \ example \ webapps (D: \ Lucene \ SOLR \ Server); and decompress SOLR. War
3. open solrconfig under conf (D: \ Lucene \ SOLR \ home \ config) in the D: \ Lucene \ SOLR \ home folder. XML, configure <datadir >$ {SOLR. data. dir :}</datadir> is (the data path is specified here)
<dataDir>${solr.data.dir:D:\lucene\solr\home\data}</dataDir>
4. set the server in Tomcat. context of XML, add the following content in
<Context path="/solr" docBase="D:\lucene\solr\server\solr" reloadable="false"></Context>
5. Set the corresponding environment variables for the context, indicating the address of the SOLR home directory (add environment in coontext ):
<Context path="/solr" docBase="D:\lucene\solr\server\solr" reloadable="false"><Environment name="solr/home" type="java.lang.String" value="D:\lucene\solr\home" override="true"/></Context>
6. Modify
<queryResponseWriter name="velocity" class="solr.VelocityResponseWriter" enable="${solr.velocity.enabled:true}"/>
Is:
<queryResponseWriter name="velocity" class="solr.VelocityResponseWriter" enable="${solr.velocity.enabled:false}"/>
Or comment out
7. start Tomcat and verify the configuration through localhost: 8080/SOLR. The following page shows that the configuration is successful.
Note: The following part may not be configured if Chinese Word Segmentation is not performed:
8. Add Chinese word segmentation (here we need to download the Chinese word segmentation package. I downloaded mmseg4j)
. Add the Chinese word segmentation package to the Lib of the server;
8.2. Define field type in schema. xml of SOLR, for example:
<fieldType name="textComplex" class="solr.TextField" > <analyzer> <tokenizer class="com.chenlb.mmseg4j.solr.MMSegTokenizerFactory" mode="complex" dicPath="dic"/> </analyzer> </fieldType><fieldType name="textMaxWord" class="solr.TextField" > <analyzer> <tokenizer class="com.chenlb.mmseg4j.solr.MMSegTokenizerFactory" mode="max-word" dicPath="dic"/> </analyzer> </fieldType><fieldType name="textSimple" class="solr.TextField" > <analyzer> <tokenizer class="com.chenlb.mmseg4j.solr.MMSegTokenizerFactory" mode="simple" dicPath="n:/OpenSource/apache-solr-1.3.0/example/solr/my_dic"/> </analyzer> </fieldType>
Dicpath specifies the dictionary location (each mmsegtokenizerfactory can specify different directories. When it is a relative directory, it is relative to SOLR. home Directory), mode specifies the word segmentation mode (simple | complex | max-word, Max-word by default ).
Copy the four files (chars. DIC; units. DIC; words. DIC; words-my.dic) in mmseg4j data to DIC.
OK, the configuration is successful, and mmseg4j Chinese word segmentation can also be used.