elasticsearch安装ik分词器

各种版本的ik分词器地址

https://github.com/medcl/elasticsearch-analysis-ik/releases?after=v6.6.0

我的elasticsearch版本6.4.2就下载相同版本的ik分词器。

分词器解压路径:elasticsearch-6.4.2\plugins 在plugins目录下新建目录analysis-ik,将下载好的分词器解压到analysis-ik中

分词器配置plugin-descriptor.properties文件:

配置java环境变量,当前es版本号,启动ik分词器类名等信息

# Elasticsearch plugin descriptor file
# This file must exist as 'plugin-descriptor.properties' at
# the root directory of all plugins.
#
# A plugin can be 'site', 'jvm', or both.
#
### example site plugin for "foo":
#
# foo.zip <-- zip file for the plugin, with this structure:
#   _site/ <-- the contents that will be served
#   plugin-descriptor.properties <-- example contents below:
#
# site=true
# description=My cool plugin
# version=1.0
#
### example jvm plugin for "foo"
#
# foo.zip <-- zip file for the plugin, with this structure:
#   <arbitrary name1>.jar <-- classes, resources, dependencies
#   <arbitrary nameN>.jar <-- any number of jars
#   plugin-descriptor.properties <-- example contents below:
#
# jvm=true
# classname=foo.bar.BazPlugin
# description=My cool plugin
# version=2.0.0-rc1
# elasticsearch.version=2.0
# java.version=1.7
#
### mandatory elements for all plugins:
#
# 'description': simple summary of the plugin
description=IK Analyzer for Elasticsearch
#
# 'version': plugin's version
version=6.4.2
#
# 'name': the plugin name
name=analysis-ik
#
# 'classname': the name of the class to load, fully-qualified.
classname=org.elasticsearch.plugin.analysis.ik.AnalysisIkPlugin
#
# 'java.version' version of java the code is built against
# use the system property java.specification.version
# version string must be a sequence of nonnegative decimal integers
# separated by "."'s and may have leading zeros
java.version=1.8
#
# 'elasticsearch.version' version of elasticsearch compiled against
# You will have to release a new version of the plugin for each new
# elasticsearch release. This version is checked when the plugin
# is loaded so Elasticsearch will refuse to start in the presence of
# plugins with the incorrect elasticsearch.version.
elasticsearch.version=6.4.2


同义词配置参考下文:

https://blog.csdn.net/qq_43077857/article/details/90511625

主要是在新建索引的时候使用同义词文件

在elasticsearch下面的config下面建立一个文件夹analysis然后在里面建立一个文本,当然最好在widow里面notepad里面建立好,这个文本名字叫synonyms.txt
一定要是utf-8编辑的

将这个文件上传

然后重启es就可以使用了

这是建立的一个映射
PUT test_index
{
“settings”: {
“number_of_shards”: 1,
“analysis”: {
“filter”: {
“my_synonym_filter”:{
“type”:“synonym”,
“synonyms_path”:“analysis/synonyms.txt”
}
},
“analyzer”: {
“ik_syno”:{
“type”:“custom”,
“tokenizer”:“ik_smart”,
“filter”:[“my_synonym_filter”]
},
“ik_syno_max”:{
“type”:“custom”,
“tokenizer”:“ik_max_word”,
“filter”:[“my_synonym_filter”]
}
}
}
},
“mappings”: {
“doc”:{
“properties”:{
“item_name”:{
“type”:“text”,
“analyzer”:“ik_syno_max”,
“search_analyzer”:“ik_syno_max”
}
}
}
}
}

插入两条数据
POST test_index/doc/1
{
“item_name”:“对违反出租车运营规定的处罚”
}

POST test_index/doc/2
{
“item_name”:“出租汽车经营者不按照规定配置出租汽车相关设备”
}

检索
GET /test_index/doc/_search
{
“query”: {
“match”: {
“item_name”: “出租车”
}
}
}两条都搜出来了因为当时将这两个设置为同义词

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值