• Windows10安装Elasticsearch IK分词插件


    安装插件

    cmd切换到Elasticsearch安装目录下

    C:UsersAdministrator>D:
    
    D:>cd D:Program FilesElasticElasticSearch6.8.4in
    

    安装的插件需要跟Elasticsearch的版本匹配,也就是说我要装的是6.8.4版本的ik分词插件。
    访问下载页面:Releases · medcl/elasticsearch-analysis-ik
    找到6.8.4的下载链接,执行以下命令

    elasticsearch-plugin install https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v6.8.4/elasticsearch-analysis-ik-6.8.4.zip
    

    执行结果示例:

    D:Program FilesElasticElasticsearch6.8.4in>elasticsearch-plugin install https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v6.8.4/elasticsearch-analysis-ik-6.8.4.zip
    -> Downloading https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v6.8.4/elasticsearch-analysis-ik-6.8.4.zip
    [=================================================] 100%??
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    @     WARNING: plugin requires additional permissions     @
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    * java.net.SocketPermission * connect,resolve
    See http://docs.oracle.com/javase/8/docs/technotes/guides/security/permissions.html
    for descriptions of what these permissions allow and the associated risks.
    
    Continue with installation? [y/N]y
    -> Installed analysis-ik
    

    不知道如何验证是否安装成功,可以先使用帮助命令elasticsearch-plugin -h查看可用的命令

    D:Program FilesElasticElasticsearch6.8.4in>elasticsearch-plugin -h
    A tool for managing installed elasticsearch plugins
    
    Commands
    --------
    list - Lists installed elasticsearch plugins
    install - Install a plugin
    remove - removes a plugin from Elasticsearch
    
    Non-option arguments:
    command
    
    Option         Description
    ------         -----------
    -h, --help     show help
    -s, --silent   show minimal output
    -v, --verbose  show verbose output
    

    由上文得出,可以使用elasticsearch-plugin list查看已安装得插件。

    D:Program FilesElasticElasticsearch6.8.4in>elasticsearch-plugin list
    analysis-icu
    analysis-ik
    

    analysis-ik ik插件已成功安装。

    测试ik分词

    测试ik分词可以由多种方式

    chrome浏览器插件elasticsearch-head

    下载地址:ElasticSearch Head - Chrome 网上应用店
    如果不能咳咳,可以访问 mobz/elasticsearch-head: A web front end for an elastic search cluster按照指示自行安装。
    测试结果类似以下界面

    kibana的Dev Tools

    Postman

    自定义词典

    词典配置IKAnalyzer.cfg.xml,我的配置路径D:ProgramDataElasticElasticsearchconfiganalysis-ik

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
    <properties>
    	<comment>IK Analyzer 扩展配置</comment>
    	<!--用户可以在这里配置自己的扩展字典 -->
    	<entry key="ext_dict"></entry>
    	 <!--用户可以在这里配置自己的扩展停止词字典-->
    	<entry key="ext_stopwords"></entry>
    	<!--用户可以在这里配置远程扩展字典 -->
    	<!-- <entry key="remote_ext_dict">words_location</entry> -->
    	<!--用户可以在这里配置远程扩展停止词字典-->
    	<!-- <entry key="remote_ext_stopwords">words_location</entry> -->
    </properties>
    

    初始配置如上所示,配置文件当前目录下,新建文本文件temp.dic
    输入以下内容,保存,不同词之间使用换行

    如家
    周树人
    

    修改配置如下,保存,然后重启Elasticsearch服务,即可使用拓展词典。

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
    <properties>
    	<comment>IK Analyzer 扩展配置</comment>
    	<!--用户可以在这里配置自己的扩展字典 -->
    	<entry key="ext_dict">temp.dic;</entry>
    	 <!--用户可以在这里配置自己的扩展停止词字典-->
    	<entry key="ext_stopwords"></entry>
    	<!--用户可以在这里配置远程扩展字典 -->
    	<!-- <entry key="remote_ext_dict">words_location</entry> -->
    	<!--用户可以在这里配置远程扩展停止词字典-->
    	<!-- <entry key="remote_ext_stopwords">words_location</entry> -->
    </properties>
    

    多个词典,以英文分号分隔。

  • 相关阅读:
    前后端交互, 安装drf, restful接口规范, pycharm断点调试
    django中文设置, axios, CORS, 全局js配置, Vue配置jq + bs
    js原型, Vue项目环境搭建, Vue项目目录结构, Vue项目生命周期, 小组件使用, 全局样式, 路由跳转, 组件的生命周期钩子, 路由传参
    Vue组件
    Vue表单指令, 条件指令, 循环指令, 成员
    question1 赋值运算操作符
    CH15 面向对象程序设计
    CH12 动态内存
    CH11 关联容器
    CH10 泛型算法
  • 原文地址:https://www.cnblogs.com/AlienXu/p/elasticsearch-analysis-ik.html
Copyright © 2020-2023  润新知