zoukankan      html  css  js  c++  java
  • ElasticSearch速学

    前面已经对”IK中文分词器“有了简单的了解: 
    这里写图片描述

    但是可以发现不是对所有的词都能很好的区分,比如: 
    这里写图片描述 
    逼格这个词就没有分出来。

    词库

    实际上IK分词器也是根据一些词库来进行分词的,我们可以丰富这个词库。 
    IK分词器(IK Analysis for Elasticsearch)给了我们一个基本的配置: 
    https://github.com/medcl/elasticsearch-analysis-ik 
    这里写图片描述

    修改我们es实例中ik插件的配置:

    cd elasticsearch-5.3.0/plugins/ik/config/

    这里写图片描述

    main.dic是住词库,stopword是停用词库(把一些错误的分词加入进来,之后不会再被分词了);custom目录中是我们的自定义词库。 
    这些词库都是本地词库。可以参考配置文档来设置。

    热更新 IK 分词使用方法

    官方文档: 
    https://github.com/medcl/elasticsearch-analysis-ik 
    这里写图片描述

    我们来配置一下:

    #进入es实例找到ik插件的配置文件
    elasticsearch-5.3.0/plugins/ik/config
    #编辑配置文件
    vi IKAnalyzer.cfg.xml

    内容:

    <?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">custom/mydict.dic;custom/single_word_low_freq.dic</entry>
         <!--用户可以在这里配置自己的扩展停止词字典-->
        <entry key="ext_stopwords">custom/ext_stopword.dic</entry>
        <!--用户可以在这里配置远程扩展字典 -->
        <entry key="remote_ext_dict">http://10.211.55.13/api/DictApi/GetDictionary</entry>
        <!--用户可以在这里配置远程扩展停止词字典-->
        <!-- <entry key="remote_ext_stopwords">words_location</entry> -->
    </properties>

    /api/DictApi/GetDictionary:

  • 相关阅读:
    一个很吊的swing循环生成窗口。
    hbase操作的问题
    hadoop+hbase
    linux故障救援
    管道命令xargs
    hadoop浅尝 hadoop与hbase交互
    linux源代码阅读笔记 free_page_tables()分析
    词法分析器flex的使用
    每天一个Linux命令(1): find
    梯度下降
  • 原文地址:https://www.cnblogs.com/a-du/p/7600474.html
Copyright © 2011-2022 走看看