1、在gitpub上搜索elasticsearch-analysis,能够看到所有elasticsearch的分词器:
2、安装IK分词器:https://github.com/medcl/elasticsearch-analysis-ik
cd /usr/share/elasticsearch/plugins/ --也可以在/data目录下 git clone https://github.com/medcl/elasticsearch-analysis-ik --下载IK Analysis for elasticsearch cd elasticsearch-analysis-ik mvn clean --maven mvn compile mvn package
mkdir /usr/share/elasticsearch/plugins/ik --在plugins目录下面创建ik目录
-- copy & unzip file #{project_path}/elasticsearch-analysis-ik/target/releases/elasticsearch-analysis-ik-*.zip to your elasticsearch's folder: plugins/ik
mv target/releases/elasticsearch-analysis-ik-1.8.0.zip ../ik
unzip elasticsearch-analysis-ik-1.8.0.zip
3、配置IK Analysis(最新版本不用加):https://www.elastic.co/guide/en/elasticsearch/reference/current/analysis.html
在elasticsearch.yml文件的末尾处加上(http://blog.csdn.net/huwei2003/article/details/40591191、http://blog.csdn.net/huwei2003/article/details/40402291)
vim /etc/elasticsearch/elasticsearch.yml
...... 末尾处添加
index: analysis: analyzer: ik: alias: [ik_analyzer] type: org.elasticsearch.index.analysis.IkAnalyzerProvider ik_max_word: type: ik use_smart: false ik_smart: type: ik use_smart: true 或 index.analysis.analyzer.ik.type: "ik"
如果是在plugins目录里面git下来的,需要删除 elasticsearch-analysis-ik目录和它下面所有的文件
rm -rf elasticsearch-analysis-ik
4、重起elasticsearch服务
service elasticsearch restart
5、测试IK分词器