搜索结果正在快递途中

elasticsearch highlight 错误

Elasticsearch | 作者 tdlLen | 发布于2020年12月10日 | 阅读数:1863

elasticsearch版本:7.4.1
索引setting和mapping设置如下:
有条数据有biz_code和c_emai字段。数据如下:
    {"biz_code": "00175755", "c_email": "dg485033524@zto.com"}。 
  
根据关键词 "00175755" 在should里使用 term对biz_code查询,match_phrase对c_email字段查询,查询结果中对c_email字段高亮了。但是单独使用match_phrase没匹配到数据。
搜索语法如下:

GET /baohe_query_ec_employee/_search?track_total_hits=true&preference=1
{
"_source": [
"c_email",
"biz_code"
],
"from": 0,
"highlight": {
"fields": {
"biz_code": {},
"c_email.email": {}
},
"post_tags": ">",
"pre_tags": "<"
},
"query": {
"function_score": {
"query": {
"bool": {
"should": [
{
"term": {
"biz_code": {
"boost": 100,
"value": "00175755"
}
}
}
]
}
}
}
},
"size": 1
}

GET /baohe_query_ec_employee/_search?track_total_hits=true&preference=1
{
"_source": [
"c_email",
"biz_code"
],
"from": 0,
"highlight": {
"fields": {
"biz_code": {},
"c_email.email": {}
},
"post_tags": ">",
"pre_tags": "<"
},
"query": {
"function_score": {
"query": {
"bool": {
"should": [
{
"term": {
"biz_code": {
"boost": 100,
"value": "00175755"
}
}
},
{
"match_phrase": {
"c_email.email": {
"query": "00175755"
}
}
}
]
}
}
}
},
"size": 1
}

 
 
"mapping":{
"properties": {
"biz_code": {
"type": "keyword"
},
"c_email": {
"type": "keyword",
"fields": {
"email": {
"type": "text",
"analyzer": "email_analyzer"
},
"standard": {
"type": "text",
"analyzer": "standard"
}
}
}
}
},
"settings":{
"analyzer": {
"email_analyzer": {
"filter": [
"lowercase",
"asciifolding"
],
"char_filter": [
"email_filter"
],
"type": "custom",
"tokenizer": "email_tokenizer"
},
},
"tokenizer": {
"email_tokenizer": {
"pattern": "[A-Za-z0-9_]",
"type": "simple_pattern"
},
},
"filter": {
"char_filter": {
"email_filter": {
"pattern": "@\\w+\\.[a-zA-Z]+",
"type": "pattern_replace",
"replacement": ""
}
}
}
}
已邀请:

要回复问题请先登录注册