Elasticsearch7.X 中 highlight 如何联合查询高亮显示
查询内容:
{
"query": {
"bool": {
"must" : {
"term" : { "_id" : 2 }
},
"should": [{
"bool": {
"must": [{
"match": {
"content": "看到"
}
}, {
"match": {
"content": "3000"
}
}]
}
}, {
"bool": {
"must": [{
"match": {
"content": "没有"
}
}, {
"match": {
"content": "第三方"
}
}]
}
}],
"minimum_should_match": 1
}
},
"highlight": {
"fields": {
"content": {
"type": "unified"
}
},
"pre_tags": ["<font color='red'>"],
"post_tags": ["</font>"]
}
}
匹配结果:
{
"took" : 1,
"timed_out" : false,
"_shards" : {
"total" : 1,
"successful" : 1,
"skipped" : 0,
"failed" : 0
},
"hits" : {
"total" : {
"value" : 1,
"relation" : "eq"
},
"max_score" : 2.4251623,
"hits" : [
{
"_index" : "quilty_test",
"_type" : "_doc",
"_id" : "1",
"_score" : 2.4251623,
"_source" : {
"content" : "下有没有看到就那个他们说他们我看了那个3000的面"
},
"highlight" : {
"content" : [
"下有<font color='red'>没有</font><font color='red'>看到</font>就那个他们说他们我看了那个<font color='red'>3000</font>的面"
]
}
}
]
}
}
想要的效果:
我是想当匹配到“没有”和“第三方”的时候才会高亮<font color='red'>没有</font>xxx<font color='red'>第三方</font>
只有一个匹配的时候 都不高亮 显示 “没有”
请问应该怎么查询?