ES版本 7.17.3
GET v2-vmail-inbox-local-000001/_search?routing=1111
{
"sort": [
{
"receive_time": {
"order": "desc"
}
}
],
"profile": true,
"size": 50,
"_source": ["mail_subject"],
"query":{
"bool": {
"filter": [
{"term": {
"receiver_code": "1111"
}},
{
"multi_match": {
"query": "df33",
"type": "phrase_prefix",
"fields": ["sender_name","mail_subject"]
}}
]
}
}
}
当我使用这样的DSL时,我无法搜到 阅读通知:DF33760BF_X4这样的数据
但我使用df337这种语句就可以搜到
我用profile发现term和multi_match并没有特别的先后关系,导致multi_match查询的前50个term没有命中到DF33760BF_X4这种数据
有没有什么办法能先满足term条件,在term条件满足的数据上在进行multi_match的匹配,从而避免max_expansions默认50 匹配不到数据的问题
样例数据可参考
POST v2-vmail-inbox-local-000001/_doc/1111-125830ed339e4e49ad5ffa84d7ee6d08?routing=1111
{
"receiver_code" : "1111",
"mail_subject" : "阅读通知:DF33760BF_X4",
"receive_time" : 1651802115000,
"sender_name" : "test",
"mail_code" : "125830ed339e4e49ad5ffa84d7ee6d08",
"sender_code" : "2222",
"receiver_name" : "测试用户"
}