我有点怀疑你在刷屏

search_template支持高亮吗?高亮无效

Elasticsearch | 作者 alphabing | 发布于2018年11月14日 | 阅读数:2249

为了方便,在项目中配置了搜索模板,用的5.4版本
# 增加模版 
POST _search/template/full_text_normal
{
"query": {
"bool": {
"must": [
{
"match": {
"full_text": "{{full_text}}"
}
}
]
}
},
"highlight": {
"require_field_match": false,
"fields": {
"full_text": {},
"title": {},
"content": {}
}
}
}
但是在使用过程中,这个高亮不起作用,
如果在搜索的时候增加高亮就会报错,如下
POST script_es/_search/template
{
"id":"full_text_normal",
"params":{
"full_text":"kaishi好开始 好"
},
"highlight": {
"require_field_match": false,
"fields": {
"full_text": {},
"title": {},
"content": {}
}
}
}


错误信息如下
{
"error": {
"root_cause": [
{
"type": "illegal_argument_exception",
"reason": "[search_template] unknown field [highlight], parser not found"
}
],
"type": "illegal_argument_exception",
"reason": "[search_template] unknown field [highlight], parser not found"
},
"status": 400
}
已邀请:

rochy - rochy_he

赞同来自:

full_text 这个字段的高亮应该是没有问题的吧,其他字段不参与搜索因此没有进行高亮

要回复问题请先登录注册