1:首先在tomcat下面的solr.war下lib中加入:IKAnalyzer2012FF_u1.jar包(不是tomcat的ilb目录)
2:然后再solr词库目录C:\solr\collection1\conf下的schema.xml文件中加入:
<!--这里让title字段使用我们的自定义数据类型:text_ik,这样就可以用我们的指定的IK分词器了-->
<field name="title" type="text_ik" indexed="true" stored="true"/>
<fieldType name="text_ik" class="solr.TextField">
<analyzer class="org.wltea.analyzer.lucene.IKAnalyzer" />
</fieldType>
就可以了,在solr界面中analys选则 type下的 text_ik就可以分词了
注意:如果出现以下错误
- collection1: org.apache.solr.common.SolrException:org.apache.solr.common.SolrException: Could not load conf for core core1: Plugin init failure for [schema.xml] fieldType "text_ik": Cannot load analyzer: org.wltea.analyzer.lucene.IKAnalyzers. Schema file is D:\test\solr\collection1\conf\schema.xml
- Please check your logs for more information
请检查以下字段是否重复,如有重复请删除
<field name="title" type="text_general" indexed="true" stored="true" multiValued="true"/>