zoukankan      html  css  js  c++  java
  • Ik分词器没有使用---------elasticsearch-analysis-ik 5.6.3分词问题

     

    1.问题

    现在项目中用的是ES5.6.3的版本,在解决Field注解没有加载mapping的问题后又发现IK分词好像不理想。

    后来查看5.5.0 IKAnalyzer.cfg.xml的配置发现

    <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">words_location</entry> -->
        <!--用户可以在这里配置远程扩展停止词字典-->
        <!-- <entry key="remote_ext_stopwords">words_location</entry> -->
    </properties>

    这里Ik是默认帮我们配置了分词的文件,这些文件是IK已经分过的词。

    然后再查看5.6.3IK的配置文件

    <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>

    5.6.3并没有帮我们去配置分词文件的位置。

    接下来查看一下源码

    加载配置文件的文件名都不对。

    接下来通过修改文件把文件名与源码中的名称对应,发现还是加载不了。 最后通过修改配置文件。

    <properties>
        <comment>IK Analyzer 扩展配置</comment>
        <!--用户可以在这里配置自己的扩展字典 -->
        <entry key="ext_dict">extra_main.dic;extra_single_word_low_freq.dic</entry>
         <!--用户可以在这里配置自己的扩展停止词字典-->
        <entry key="ext_stopwords">extra_stopword.dic</entry>
        <!--用户可以在这里配置远程扩展字典 -->
        <!-- <entry key="remote_ext_dict">words_location</entry> -->
        <!--用户可以在这里配置远程扩展停止词字典-->
        <!-- <entry key="remote_ext_stopwords">words_location</entry> -->
    </properties>

    这下就可以正常的分词了。

    参考-----https://github.com/medcl/elasticsearch-analysis-ik/issues/602

                

  • 相关阅读:
    SET TRANSACTION
    SET SESSION AUTHORIZATION
    SET CONSTRAINTS
    SET
    services
    send, sendto, sendmsg
    并列句分析
    cURL 学习笔记与总结(3)模拟登录博客园并下载个人随笔首页
    SQLServer2019安装教程
    Java实现 LeetCode 85 最大矩形
  • 原文地址:https://www.cnblogs.com/technologykai/p/9831704.html
Copyright © 2011-2022 走看看