infinilabs / analysis-pinyin

🛵 This Pinyin Analysis plugin is used to do conversion between Chinese characters and Pinyin.
Apache License 2.0
2.94k stars 547 forks source link

pinyin搜索,怎么高亮显示对应中文 7.9.3版本 #256

Closed xiaohoutongxue closed 3 years ago

xiaohoutongxue commented 3 years ago

mapping: { "article" : { "mappings" : { "properties" : { "_class" : { "type" : "text", "fields" : { "keyword" : { "type" : "keyword", "ignore_above" : 256 } } }, "content" : { "type" : "text", "fields" : { "pinyin" : { "type" : "text", "analyzer" : "pinyin" } }, "analyzer" : "ik_max_word" }, "createTime" : { "type" : "long" }, "title" : { "type" : "text", "fields" : { "pinyin" : { "type" : "text", "analyzer" : "pinyin" } }, "analyzer" : "ik_max_word" } } } } }

搜索 GET /article/_search { "query":{ "multi_match": { "query": "shenshang", "fields": ["content.pinyin"] } }, "highlight": { "pre_tags" : [""], "post_tags" : [""], "fields": { "content.pinyin": {} } } }

结果: "highlight" : { "content.pinyin" : [ "迪斯科浪费空间四点零分了是对方身上的" ] }

怎么让这个pre_tags 打在 对应拼音的汉字上呢