最新消息:XAMPP默认安装之后是很不安全的,我们只需要点击左方菜单的 "安全"选项,按照向导操作即可完成安全设置。

ik分词器安装

XAMPP下载 admin 4580浏览 0评论
 安装ik分词器有2种方式1、下载Elasticsearch对应版本的ik包,然后解压致Elasticsearch中。
ik和ES的版本对应

下载对应版本的ik

解压
在ES的conf和plugins文件夹下各自新建一个analysis-ik的文件夹
将解压后以下文件中除config文件夹外的全部拷贝到plugins文件夹下的analysis-ik文件夹中
es中plugins最终结果
将解压后文件config文件夹内的全部文件拷贝到conf文件夹下的analysis-ik文件夹中
es中conf/analysis-ik的最终结果2、linux中通过命令直接安装。执行-plugin 安装
./bin/elasticsearch-plugin install https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v6.2.3/elasticsearch-analysis-ik-6.2.3.zip

最后重启ES1.查找ES进程ps -ef | grep elastic2.杀掉ES进程kill -9 2382(进程号)3.重启ESsh elasticsearch -d
验证ik分词器是否使用1.通过Rest方式创建 index
【PUT】 http://ip:9200/index2

通过Rest方式创建 mapping
【POST】 http://ip:9200/index/fulltext/_mapping

请求头Content-Type=’Content-Type:application/json’
参数
{
“properties”: {
“content”: {
“type”: “text”,
“analyzer”: “ik_max_word”,
“search_analyzer”: “ik_max_word”
}
}

}

3.通过Rest方式插入一些数据
【POST】 http://ip:9200/index/fulltext/1Content-Type=

‘Content-Type:application/json’
参数
{“content”:”美国留给伊拉克的是个烂摊子吗”}
【POST】 http://ip:9200/index/fulltext/2Content-Type=

‘Content-Type:application/json’
参数
{“content”:”公安部:各地校车将享最高路权”
【POST】 http://ip:9200/index/fulltext/3Content-Type=

‘Content-Type:application/json’
参数
{“content”:”中韩渔警冲突调查:韩警平均每天扣1艘中国渔船”
【POST】 http://ip:9200/index/fulltext/4Content-Type=

‘Content-Type:application/json’
参数
{“content”:”中国驻洛杉矶领事馆遭亚裔男子枪击 嫌犯已自首”}

4.通过Rest方式查询测试【POST】 http://ip:9200/index/fulltext/_searchContent-Type=

‘Content-Type:application/json’
参数
{
“query” : { “match” : { “content” : “中国” }},
“highlight” : {
“pre_tags” : [“<tag1>”, “<tag2>”],
“post_tags” : [“</tag1>”, “</tag2>”],
“fields” : {
“content” : {}
}
}

请求返回
{
“took”: 14,
“timed_out”: false,
“_shards”: {
“total”: 5,
“successful”: 5,
“failed”: 0
},
“hits”: {
“total”: 2,
“max_score”: 2,
“hits”: [
{
“_index”: “index”,
“_type”: “fulltext”,
“_id”: “4”,
“_score”: 2,
“_source”: {
“content”: “中国驻洛杉矶领事馆遭亚裔男子枪击 嫌犯已自首”
},
“highlight”: {
“content”: [
“<tag1>中国</tag1>驻洛杉矶领事馆遭亚裔男子枪击 嫌犯已自首 ”
]
}
},
{
“_index”: “index”,
“_type”: “fulltext”,
“_id”: “3”,
“_score”: 2,
“_source”: {
“content”: “中韩渔警冲突调查:韩警平均每天扣1艘中国渔船”
},
“highlight”: {
“content”: [
“均每天扣1艘<tag1>中国</tag1>渔船 ”
]
}
}
]
}
}

转载请注明:XAMPP中文组官网 » ik分词器安装

您必须 登录 才能发表评论!