• ik_max_word ik_smart


    打开 ~/es_root/config/elasticsearch.yml 文件,加入以下配置:

    index:
      analysis:
        analyzer:
          ik_syno:
              type: custom
              tokenizer: ik_max_word
              filter: [my_synonym_filter]
          ik_syno_smart:
              type: custom
              tokenizer: ik_smart
              filter: [my_synonym_filter]
        filter:
          my_synonym_filter:
              type: synonym
              synonyms_path: analysis/synonym.txt

    以上配置定义了 ik_syno 和 ik_syno_smart 这两个新的 analyzer,分别对应 IK 的 ik_max_word 和 ik_smart 两种分词策略。根据 IK 的文档,二者区别如下:

    • ik_max_word:会将文本做最细粒度的拆分,例如「中华人民共和国国歌」会被拆分为「中华人民共和国、中华人民、中华、华人、人民共和国、人民、人、民、共和国、共和、和、国国、国歌」,会穷尽各种可能的组合;
    • ik_smart:会将文本做最粗粒度的拆分,例如「中华人民共和国国歌」会被拆分为「中华人民共和国、国歌」;

    ik_syno 和 ik_syno_smart 都会使用 synonym filter 实现同义词转换。为了方便后续测试,建议创建 ~/es_root/config/analysis/synonym.txt 文件,输入一些同义词并存为 utf-8 格式。例如:

    ua,user-agent,userAgent
    js,javascript
  • 相关阅读:
    科研道路上培养的7种能力
    (OK) network diagnose tools
    linux-bridge-ping-high-latency-ebtables.txt
    houshoul
    Android x86 Virtual box with Internet and connection to adb?
    linux內核調試kmsg,dmesg
    Android Logging System
    Linux 日志级别(loglevel)详解
    Linux之绝处逢生------SysRq
    /proc/sysrq-trigger详解
  • 原文地址:https://www.cnblogs.com/softidea/p/6081285.html
Copyright © 2020-2023  润新知