下载
Index of: analysis-ik/stable/
查找对应版本下载
安装
将压缩包上传到服务器es安装路径下plugin目录,如我的安装在/usr/local下。
在plugin下新建analysis-ik文件夹,将zip文件解压到analysis-ik目录下.
修改目录及目录下所有文件的用户和用户组,chown -R /usr/local/elasticsearch
重启es
找到elasticsearch的bin文件,使用./elasticsearch启动,可以看到类似输出。
使用./elasticsearch -d代表背景启动
校验
找到elasticsearch的bin文件,使用./elasticsearch-plugin list 检察
大概在可视化客户端,实行
索引字段设置ik分词器
注意:如果此索引已存在数据,则不能通过次方式修改分词器
- PUT /esb-m-produce-logs-000029/_mapping
- {
- "properties": {
- "msgContent": {
- "type": "text",
- "analyzer": "ik_max_word",
- "search_analyzer": "ik_smart"
- }
- }
- }
复制代码 可选方式:
1.删除并重新创建索引
如果你可以删除现有的索引并重新创建它,这是最简朴的方法。请注意,这将导致所有现有数据丢失。
- DELETE /your_index
- PUT /your_index
- {
- "settings": {
- "analysis": {
- "analyzer": {
- "ik_max_word": {
- "type": "ik_max_word"
- },
- "ik_smart": {
- "type": "ik_smart"
- }
- }
- }
- },
- "mappings": {
- "properties": {
- "msgContent": {
- "type": "text",
- "analyzer": "ik_max_word",
- "search_analyzer": "ik_smart"
- }
- }
- }
- }
复制代码 2. 使用新的索引和重索引数据
如果不能删除现有索引,你可以创建一个新索引,并将数据从旧索引重索引到新索引。
- PUT /new_index
- {
- "settings": {
- "analysis": {
- "analyzer": {
- "ik_max_word": {
- "type": "ik_max_word"
- },
- "ik_smart": {
- "type": "ik_smart"
- }
- }
- }
- },
- "mappings": {
- "properties": {
- "msgContent": {
- "type": "text",
- "analyzer": "ik_max_word",
- "search_analyzer": "ik_smart"
- }
- }
- }
- }
- POST /_reindex
- {
- "source": {
- "index": "old_index"
- },
- "dest": {
- "index": "new_index"
- }
- }
复制代码 3. 更新映射(仅适用于某些情况)
在某些情况下,你大概可以或许更新映射而不会导致冲突。这通常适用于添加新的字段或更新非冲突的设置。然而,对于更改现有字段的分词器,这种方法大概不适用。
4. 使用别名(Alias)
如果你不想删除旧索引,可以使用别名来切换到新索引。起首创建新索引并重索引数据,然后将别名指向新索引。
- POST /_aliases
- {
- "actions": [
- { "remove": { "index": "old_index", "alias": "my_alias" }},
- { "add": { "index": "new_index", "alias": "my_alias" }}
- ]
- }
复制代码
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。 |