美文网首页
Elastict文档

Elastict文档

作者: 知道吗123 | 来源:发表于2017-09-19 13:18 被阅读0次

    GitHub IK插件地址

    https://github.com/medcl/elasticsearch-analysis-ik

    需要注意IK插件的版本,要和ElasticSearch对应,否则出错(而且应该按照第二种命令的方式进行下载,简单不易错,开始按照第一种出现了找不到文件的错误)

    1.安装方式

    optional 1 - download pre-build package from here: https://github.com/medcl/elasticsearch-analysis-ik/releases
    unzip plugin to folder your-es-root/plugins/

    optional 2 - use elasticsearch-plugin to install ( version > v5.5.1 ):
    ./bin/elasticsearch-plugin install https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v5.6.1/elasticsearch-analysis-ik-5.6.1.zip

    IK version ES version
    5.6.1 5.6.1
    5.5.3 5.5.3

    我用optional1没有成功,就用optional2了,elaticsearch支持的插件安装程序
    cd elasticsearh-root-dir
    然后复制该命令到命令行 回车即可

    2.安装完成之后可以测试效果对比

    1.测试内置的"standard"标准分析器效果

    curl -XPOST http://localhost:9200/_analyze?pretty -d '{
      "analyzer": "standard",
      "text":  "庖丁解牛成语中文english test"
    }'
    

    2.测试刚刚安装好的ik分词分析器插件的效果

    curl -XPOST http://localhost:9200/_analyze?pretty -d '{
    "analyzer": "ik_max_word",
    "text":  "庖丁解牛成语中文english test"
    }'
    

    3.GitHub上复制的原话(就用ik_max_word靠谱)

    移除名为 ik 的analyzer和tokenizer,请分别使用 ik_smart 和 ik_max_word
    ik_max_word 和 ik_smart 什么区别?
    ik_max_word: 会将文本做最细粒度的拆分,比如会将“中华人民共和国国歌”拆分为“中华人民共和国,中华人民,中华,华人,人民共和国,人民,人,民,共和国,共和,和,国国,国歌”,会穷尽各种可能的组合;
    ik_smart: 会做最粗粒度的拆分,比如会将“中华人民共和国国歌”拆分为“中华人民共和国,国歌”。

    4.ElasticSearch Reference的地址:剖析Analyzer

    Anlyzer由character filter+tokenizer+token filter组成,添加的这个ik实际上主要是tonkenizer分词器的效果,之后要改可以和其他filter组合
    IK的Git上的一句话:Analyzer: ik_smart , ik_max_word , Tokenizer: ik_smart , ik_max_word
    组合示例(这个就是看一下,不能复制直接用)
    POST _analyze
    {
    "tokenizer": "standard",
    "filter": [ "lowercase", "asciifolding" ],
    "text": "Is this déja vu?"
    }

    3.IK热更新:IK Analysis for Elasticsearch

    修改 elasticsearch-root-dir/config/analysis-ik/IKAnalyzer.cfg.xml

    <!--用户可以在这里配置远程扩展字典 --> 
    <entry key="remote_ext_dict">http://localhost:8080/elasticsearch/ik/remote_my_dict.txt</entry>
    

    其实配置好那个url就可以,随便用什么可以被访问的http服务器就行(我在linux弄的tomcat)
    配置好之后在remote_my_dict.txt中随时添加词就可以,不用重启elasticsearch的服务(但是加完词,测试查询不会立马生效,得过个10多秒,不知道具体怎么回事.估计是用定时器去特定时间发送那个链接的请求吧) `

    相关文章

      网友评论

          本文标题:Elastict文档

          本文链接:https://www.haomeiwen.com/subject/cdewsxtx.html