Solr 7.2安装实例与中文分词器

Solr 7.2安装实例与中文分词器

一、安装实例

1、创建实例目录

[root@node004]# mkdir -p /usr/local/solr/home/jonychen

2、复制实例相关配置文件

[root@node004]# cp   /usr/local/solr/home/configsets/_default/conf   -rf    /usr/local/solr/home/jonychen

3、修改solrConfig.xml

[root@node004]# cp  /root/solr-7.2.0/contrib -rf /usr/local/solr/home/
[root@node004]# cp  /root/solr-7.2.0/dist -rf /usr/local/solr/home/

[root@node004]# vi  /usr/local/solr/home/jonychen/conf/solrconfig.xml

Solr 7.2安装实例与中文分词器

4、  通过管理控制台创建

Solr 7.2安装实例与中文分词器

创建实例成功

Solr 7.2安装实例与中文分词器

 

二、  安装中文分词器

1、复制jar包

[root@node004 ~]# cd    /usr/local/solr/home/contrib/analysis-extras/lucene-libs/

[root@node004 lucene-libs]# cp lucene-analyzers-smartcn-7.2.0.jar     /usr/local/solr/apache-tomcat-8.5.24/webapps/solr/WEB-INF/lib/

2、修改managed-schema

[root@node004 ~]# cd /usr/local/solr/home/jonychen/conf

[root@node004 conf]# vi managed-schema 

Solr 7.2安装实例与中文分词器

中文分词器

<!-- ChineseAnalyzer -->
<fieldType name="solr_cnAnalyzer" class="solr.TextField" positionIncrementGap="100">
  <analyzer type="index">
    <tokenizer class="org.apache.lucene.analysis.cn.smart.HMMChineseTokenizerFactory"/>
  </analyzer>
  <analyzer type="query">
    <tokenizer class="org.apache.lucene.analysis.cn.smart.HMMChineseTokenizerFactory"/>
  </analyzer>
</fieldType>

 修改默认分词器为中文分词器

Solr 7.2安装实例与中文分词器

3、  重新启动tomcat

[root@node004]#  /usr/local/solr/apache-tomcat-8.5.24

[root@node004 apache-tomcat-8.5.24]# ./bin/shutdown.sh

[root@node004 apache-tomcat-8.5.24]# jps
2670 Jps
[root@node004 apache-tomcat-8.5.24]# ps -ef | grep java
root 2681 1988 0 06:10 pts/0 00:00:00 grep java
[root@node004 apache-tomcat-8.5.24]# ./bin/startup.sh
Using CATALINA_BASE: /usr/local/solr/apache-tomcat-8.5.24
Using CATALINA_HOME: /usr/local/solr/apache-tomcat-8.5.24
Using CATALINA_TMPDIR: /usr/local/solr/apache-tomcat-8.5.24/temp
Using JRE_HOME: /usr/local/java/jdk1.8.0_111
Using CLASSPATH: /usr/local/solr/apache-tomcat-8.5.24/bin/bootstrap.jar:/usr/local/solr/apache-tomcat-8.5.24/bin/tomcat-juli.jar
Tomcat started.
[root@node004 apache-tomcat-8.5.24]# tailf ./logs/catalina.out

4、测试

Solr 7.2安装实例与中文分词器

相关推荐