elasticsearch-7.15.2 同时支持中文ik分词器和pinyin分词器
生活随笔
收集整理的這篇文章主要介紹了
elasticsearch-7.15.2 同时支持中文ik分词器和pinyin分词器
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
文章目錄
- 1. 自定義分詞器
- 2. 映射模型
- 3. 效果圖
1. 自定義分詞器
ES如何支持拼音和中文分詞 ?
自定義分詞器 支持拼音和中文分詞
2. 映射模型
重新指定文檔類型映射拼音分詞類型
POST /jd_goods/_mapping {"properties": {"title": {"type": "text","analyzer": "ik_max_word_pinyin","search_analyzer": "ik_smart_pinyin"},"desc": {"type": "text","analyzer": "ik_max_word_pinyin","search_analyzer": "ik_smart_pinyin"},"img": {"type": "text"},"price": {"type": "text"}} }1.和2.可以合并為下面這一條命令
PUT /jd_goods {"settings": {"analysis": {"analyzer": {"ik_smart_pinyin": {"type": "custom","tokenizer": "ik_smart","filter": ["my_pinyin", "word_delimiter"]},"ik_max_word_pinyin": {"type": "custom","tokenizer": "ik_max_word","filter": ["my_pinyin", "word_delimiter"]}},"filter": {"my_pinyin": {"type" : "pinyin","keep_separate_first_letter" : true,"keep_full_pinyin" : true,"keep_original" : true,"limit_first_letter_length" : 16,"lowercase" : true,"remove_duplicated_term" : true}}}},"mappings": {"properties": {"title": {"type": "text","analyzer": "ik_max_word_pinyin","search_analyzer": "ik_smart_pinyin"},"desc": {"type": "text","analyzer": "ik_max_word_pinyin","search_analyzer": "ik_smart_pinyin"},"img": {"type": "text"},"price": {"type": "text"}}} }3. 效果圖
- 拼音搜索
- 中文搜索
具體詳細:
請參考elasticsearch-7.15.2 配置IK中文分詞器+拼音分詞
總結
以上是生活随笔為你收集整理的elasticsearch-7.15.2 同时支持中文ik分词器和pinyin分词器的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: nginx 1.9.9 Linux 环境
- 下一篇: 搭建 ELK 集群 kafka file