起因:
针对A字段,既需要做分词处理,有需要做聚合统计处理,因此为这个字段配置了多个类型,index和mapping如下
"analysis": {
"analyzer": {
"comma_analyzer": {
"tokenizer": "comma"
},
"pinyin_analyzer": {
"tokenizer": "my_pinyin"
}
},
"tokenizer": {
"comma": {
"pattern": ",",
"type": "pattern"
},
"my_pinyin": {
"keep_none_chinese_in_first_letter": "true",
"lowercase": "true",
"first_letter": "prefix",
"keep_original": "true",
"remove_duplicated_term": "true",
"keep_first_letter": "true",
"keep_separate_first_letter": "true",
"trim_whitespace": "true",
"type": "pinyin",
"keep_none_chinese": "true",
"limit_first_letter_length": "16",
"keep_full_pinyin": "true"
}
}
}
"mappings": {
"service": {
"properties": {
"关于中心": {
"analyzer": "ik_max_word",
"type": "text",
"fields": {
"comma": {
"fielddata": true,
"analyzer": "comma_analyzer",
"type": "text"
},
"suggest": {
"max_input_length": 50,
"analyzer": "pinyin_analyzer",
"preserve_position_increments": true,
"type": "completion",
"preserve_separators": true
},
"keyword": {
"type": "keyword"
}
}
}
}
}
},
接下来问题出现了,在高亮检索时,使用.keyword进行精确检索和直接使用ik_max_word检索时,【.keyword】不返回高亮字段,请问有大佬知道为什么吗
highlight里面加个关于中心.keyword
当头一棒,醍醐灌顶,恍然大悟