linux/solr 4.6 和tomcat 8的安装

=== tomcat === 配置好jdk,解压tomcat,执行bin/startup.sh 启动

=== solr安装 ===

  1. 将 dist 下的solr.war 放到tomcat的webapps下。
  2. 启动tomcat 此时报错,solr.war 解压 关闭tomcat 删除solr.war
  3. 得到solr 目录
  4. 配置solr_home :将下载的solr包中解压的example/solr 文件夹copy到 /opt/solr(路径可以任意修改)。
  5. 修改tomcat/webapps/solr/WEB-INFO/web.xml {{{ solr/home /opt/solr java.lang.String }}}

或者/root/tomcat/conf/Catalina/localhost目录下建立solr文件 {{{ <?xml version="1.0" encoding="UTF-8"?> }}} 1. copy 下载包中的 example\lib\ext 下的jar包全部放到tomcat根目录下 的lib目录下 1. 启动tomcat

=== 安装分词 === {{{ wget https://mmseg4j.googlecode.com/files/mmseg4j-1.9.1.zip -O mmseg4j cp mmseg4j/dist/* /root/tomcat/webapps/solr/WEB-INFO/lib

}}} vi /opt/solr/collection1/conf/schema.xml add this lines to "fields" and "fieldtypes" {{{

<fieldtype name="textMaxWord" class="solr.TextField" positionIncrementGap="100">
    <analyzer>
        <tokenizer class="com.chenlb.mmseg4j.solr.MMSegTokenizerFactory" mode="max-word" dicPath="dic"></tokenizer>
    </analyzer>
</fieldtype>

<fieldtype name="textSimple" class="solr.TextField" positionIncrementGap="100">
    <analyzer>
        <tokenizer class="com.chenlb.mmseg4j.solr.MMSegTokenizerFactory" mode="simple" dicPath="dic"></tokenizer>
    </analyzer>
</fieldtype>

}}} open url "http://172.16.147.141:8080/solr/#/collection1/analysis" on Brower

error: {{{ TokenStream contract violation: reset()/close() call missing, reset() called multiple times, or subclass does not call super.reset(). Please see Javadocs of TokenStream class for more information about the correct consuming workflow. }}} solution: {{{ find ./ -name MMSegTokenizer.java

public void reset() throws IOException { //lucene 4.0 //org.apache.lucene.analysis.Tokenizer.setReader(Reader) //setReader 自动被调用, input 自动被设置。 super.reset(); //加这一句 mmSeg.reset(input); }

重新打包 mvn package root@debian:~/mmseg4j-1.9.1/mmseg4j-analysis/target# cp mmseg4j-analysis-1.9.2-SNAPSHOT.jar ~/tomcat/webapps/solr/WEB-INF/lib/mmseg4j-analysis-1.9.1.jar }}}

restart tomcat open url "http://172.16.147.141:8080/solr/#/collection1/analysis" on Brower

Comments !