4591566 发表于 2017-12-20 12:52:15

solrcloud配置中文分词器ik

  无论是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配置文件
view plain copy
[*]/usr/local/solr/server/scripts/cloud-scripts/zkcli.sh -zkhost 192.168.1.236:2181 -cmd getfile /configs/mycollection3
view plain copy
[*]/schema.xml schema.xml
  /configs/mycollection3/schema.xml #这是zookeeper上的配置文件
  schema.xml #这是下载后的文件
  修改下载的schema.xml文件
  在最后增加:
view plain copy
[*]<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分词器:
view plain copy
[*]<field name="name" type="text_ik" indexed="true" stored="true"/>
[*]<field name="text" type="text_ik" indexed="true" stored="true"/>
  上传修改好的配置文件schema.xml到zookeeper上
view plain copy
[*]/usr/local/solr/server/scripts/cloud-scripts/zkcli.sh -zkhost 192.168.1.236:2181 -cmd putfile /configs/mycollection2
view plain copy
[*]/schema.xmlschema.xml
  /configs/mycollection3/schema.xml #这是zookeeper上的配置文件
  schema.xml #这是修改后的文件
  重新启动tomcat后测试:

  
页: [1]
查看完整版本: solrcloud配置中文分词器ik