Elasticsearch5.5.1安装IK中文分词器

Elasticsearch5.5.1安装 参考:https://codeday.me/collect/20180515/163461.html

一、参照官方文档安装IK分词器

方法1、使用elasticsearch-plugin命令安装(推荐)

./bin/elasticsearch-plugin install https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v5.5.1/elasticsearch-analysis-ik-5.5.1.zip

方法2、直接到https://github.com/medcl/elasticsearch-analysis-ik/releases下载对应版本zip包,解压到elasticsearch的plugin目录下

unzip elasticsearch-analysis-ik-5.5.1.zip

重新启动elasticsearch

测试分词:

http://localhost:9200/customindex/_analyze?analyzer=ik_max_word&pretty=true&text=Elasticsearch5.5.1安装IK中文分词器

测试查询:

1、创建索引

curl -XPUT http://localhost:9200/customindex

2、创建一个映射

curl -XPOST http://localhost:9200/customindex/customtype/_mapping -d'
{
"properties": {
"content": {
"type": "text",
"analyzer": "ik_max_word",
"search_analyzer": "ik_max_word"
}
}
}'

3、创建文档

curl -XPOST http://localhost:9200/customindex/customtype/custom1 -d'

{"content":"Elasticsearch5.5.1安装IK中文分词器"}’

4、查询

curl -XPOST http://localhost:9200/customindex/customtype/_search -d'
{
"query" : { "match" : { "content" : "中文" }}
}’

转载注明原文:Elasticsearch5.5.1安装IK中文分词器