solrcloud配置中文分词器ik

来源:互联网 发布:淘宝hd ipad 编辑:程序博客网 时间:2024/05/16 16:19

无论是solr还是luncene,都对中文分词不太好,所以我们一般索引中文的话需要使用ik中文分词器。

三台机器(192.168.1.236,192.168.1.237,192.168.1.238)已经安装好了solrcloud

我安装的是solr5.5使用的是ik是IKAnalyzer2012FF_u2.rar

下载IKAnalyzer2012FF_u2.rar下载地址:http://download.csdn.net/detail/sunqingzhong44/9835849

一下步骤三台机器都要操作

下载后进行进行解压

复制IKAnalyzer2012FF_u2.jar到tomcat/weapps/solr/WEB-INF/lib/下

复制ext.dic,IKAnalyzer.cfg.xml到tomcat/weapps/solr/WEB-INF/classes下

一下操作只在一台机器上操作即可

下载collection在zookeeper上所对应的schema.xml配置文件

/usr/local/solr/server/scripts/cloud-scripts/zkcli.sh -zkhost 192.168.1.236:2181 -cmd getfile /configs/mycollection3
/schema.xml schema.xml

/configs/mycollection3/schema.xml #这是zookeeper上的配置文件
schema.xml #这是下载后的文件


修改下载的schema.xml文件

在最后增加:

 <fieldType name="text_ik" class="solr.TextField">        <analyzer type="index" useSmart="false" isMaxWordLength="false" class="org.wltea.analyzer.lucene.IKAnalyzer"></analyzer>        <analyzer type="query" useSmart="true"  isMaxWordLength="true" class="org.wltea.analyzer.lucene.IKAnalyzer"></analyzer>    </fieldType>

可以在定义域的时候使用ik分词器:

 <field name="name" type="text_ik" indexed="true" stored="true"/>   <field name="text" type="text_ik" indexed="true" stored="true"/>

上传修改好的配置文件schema.xml到zookeeper上

 /usr/local/solr/server/scripts/cloud-scripts/zkcli.sh -zkhost 192.168.1.236:2181 -cmd putfile /configs/mycollection2
/schema.xml  schema.xml

/configs/mycollection3/schema.xml #这是zookeeper上的配置文件
schema.xml #这是修改后的文件

重新启动tomcat后测试:






0 0