对本地Solr服务器添加IK中文分词器实现全文检索功能
首先下载IK中文分词项目,下载地址https://code.google.com/archive/p/ik-analyzer/downloads?page=1,其中除了含有jar包之外,还有三个相关的配置文件
第一步,将IKAnalyzer2012FF_u1.jar添加到项目的WEB-INF\lib目录下
第二步,将IKAnalyzer.cfg.xml与stopword.dic添加到项目的classes目录下
其中的ext.dic文件可手动进行扩展字典配置,在IKAnalyzer.cfg.xml配置文件中,我们可以看到对应的配置
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
<properties>
<comment>IK Analyzer 扩展配置</comment>
<!--用户可以在这里配置自己的扩展字典 -->
<entry key="ext_dict">ext.dic;</entry>
<!--用户可以在这里配置自己的扩展停止词字典-->
<entry key="ext_stopwords">stopword.dic;</entry>
</properties>
第三步,也就是最重要的一步,需要在schema.xml文件中配置分词类型
<fieldType name="text_ik"> <analyzer type="index" isMaxWordLength="false"/>
<analyzer type="query" isMaxWordLength="true"/>
</fieldType>
页:
[1]