1、准备
1)下载分词器:ik-analyzer
https://search.maven.org/search?q=com.github.magese
https://github.com/magese/ik-analyzer-solr
2)将分词器jar放入solr-8.1.1/server/solr-webapp/webapp/WEB-INF/lib
3)将分词器recources目录下的配置文件放入solr-8.1.1/server/solr-webapp/webapp/WEB-INF/classes下
2、配置分词器
1)修改solr-8.1.1/server/solr/meta_db/conf/managed-schema
<!-- ik分词器 -->
<fieldType name="text_ik" class="solr.TextField">
<analyzer type="index">
<tokenizer class="org.wltea.analyzer.lucene.IKTokenizerFactory" useSmart="false" conf="ik.conf"/>
<filter class="solr.LowerCaseFilterFactory"/>
</analyzer>
<analyzer type="query">
<tokenizer class="org.wltea.analyzer.lucene.IKTokenizerFactory" useSmart="true" conf="ik.conf"/>
<filter class="solr.LowerCaseFilterFactory"/>
</analyzer>
</fieldType>
2)重启solr
3)验证分词器
3、配置字段分词(将字段的type属性改为text_ik),然后重启solr
<!-- 需要中文分词,type设置为配置的txt_ik-->
<field name="name" type="text_ik" multiValued="false" indexed="true" required="true" stored="true"/>
<field name="sex" type="string" multiValued="false" indexed="true" required="true" stored="true"/>
<field name="address" type="text_ik" multiValued="false" indexed="true" required="true" stored="true"/>
<field name="updateTime" type="string" multiValued="false" indexed="true" required="true" stored="true"/>
<field name="deleted" type="string" multiValued="false" indexed="true" required="true" stored="true"/>
4、验证字段分词