安装IK分词器
下载对应版本的插件
https://github.com/medcl/elasticsearch-analysis-ik/releases
首先下载es对应版本的ik分词器的zip包,上传到es服务器上,在es的安装目录下有一个plugins的目录,在这个目录下创建一个叫ik的目录
然后将解压好的内容,拷贝到ik目录
将ik目录拷贝到其他的es节点
重新启动所有的es
#创建索引名字叫news
curl -XPUT http://192.168.100.211:9200/news
#创建mapping(相当于数据中的schema信息,表名和字段名以及字段的类型)
curl -XPOST http://192.168.100.211:9200/news/fulltext/_mapping -d'
{
"properties": {
"content": {
"type": "text",
"analyzer": "ik_max_word",
"search_analyzer": "ik_max_word"
}
}
}'
curl -XPOST http://192.168.100.211:9200/news/fulltext/1 -d'
{"content":"美国留给伊拉克的是个烂摊子吗"}'
curl -XPOST http://192.168.100.211:9200/news/fulltext/2 -d'