我有以下弹性搜索查询,其查询字符串应与所有字段匹配,术语查询应与下面给出的相应字段匹配。我只希望 query_string 成为突出显示的一部分。当我使用 required_field_match 时,它仅突出显示频道字段上的“电子邮件”一词。没有 required_field_match 它在我不想要的所有字段上匹配“电子邮件”和 query_string。你能告诉我如何从突出显示中排除“频道”字段吗?
{
"query":{
"bool":{
"must":[
{
"term":{
"channel":"email"
}
},
{
"query_string":{
"query":"\"payment type\"",
"default_operator":"AND"
}
}
]
}
},
"highlight":{
"pre_tags":[
"<span class='highlight'>"
],
"post_tags":[
"</span>"
],
"require_field_match":false,
"fields":{
"requestSummary":{
"number_of_fragments":0
},
"emails.emailBody":{
"number_of_fragments":0
},
"chatTextArray.text":{
"number_of_fragments":0
},
"chatTextArray.name":{
"number_of_fragments":0
}
}
},
"facets":{
"channel":{
"terms":{
"field":"channel"
}
},
"siteId":{
"terms":{
"field":"siteId"
}
},
"closeDt":{
"terms":{
"field":"closeDt"
}
},
"srId":{
"terms":{
"field":"srId"
}
}
}
}
搜索结果:
{
"highlight":{
"emails.emailBody":[
"helps keep your information safe, visit: http://pages.half.ebay.com/help/policy/privacy.html#toc-02
In this <span class='highlight'>email</span>"
],
"requestSummary":[
"Change <span class='highlight'>payment</span> <span class='highlight'>type</span>"
]
}
}