Elasticsearch默认会用<em></em>标签标记关键字, 其实我们可以自定义标签
自定义搜索高亮
自定义strong标签
GET books/_search
{
"query": {
"match": {
"title": "javascript"
}
},
"highlight": {
"fields": {
"title": {
"pre_tags": ["<strong>"],
"post_tags": ["</strong>"]
}
}
}
}
多字段高亮
GET books/_search
{
"query": {
"match": {
"title": "javascript"
}
},
"highlight": {
"require_field_match": "false",
"fields": {
"title": {},
"description": {}
}
}
}