zoukankan      html  css  js  c++  java
  • 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
  • 相关阅读:
    String为值类型还是引用类型
    Mat数据类型
    各数据类型取值范围和所占字节数
    opencv matType
    python函数参数中冒号与箭头
    批量删除list中元素的方法
    PyQt QListview和QListWidgt
    函数形参中的冒号与箭头
    CSS选择器之相邻兄弟选择器
    CSS选择器之子元素选择器
  • 原文地址:https://www.cnblogs.com/softidea/p/6081285.html
Copyright © 2011-2022 走看看