网站制作网站建设单位,昆明网站推广优化,吉林省白山市建设局官方网站,甘肃省建设厅质量投诉网站文章目录1. 自定义分词器2. 映射模型3. 效果图1. 自定义分词器
ES如何支持拼音和中文分词 #xff1f; 自定义分词器 支持拼音和中文分词
PUT /jd_goods
{settings: {analysis: {analyzer: {ik_smart_pinyin: {type 自定义分词器 支持拼音和中文分词
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}}}}
}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中文分词器拼音分词