如下查询中function_score的functions内filter的boost值无效,只weight有效
{
"from" : 0,
"size" : 20,
"query" : {
"function_score" : {
"query" : {
"bool" : {
"should" : [
{"term":{"from":1}}
]
}
},
"functions" : [
{
"filter" : {
"match_phrase" : {
"cnName" : {
"query" : "苏州",
"slop" : 0,
"boost" : 10000.0
}
}
},
"weight" : 1.0
}
],
"score_mode" : "sum",
"boost_mode" : "sum",
"max_boost" : 3.4028235E38,
"boost" : 1.0
}
}
}
{
"from" : 0,
"size" : 20,
"query" : {
"function_score" : {
"query" : {
"bool" : {
"should" : [
{"term":{"from":1}}
]
}
},
"functions" : [
{
"filter" : {
"match_phrase" : {
"cnName" : {
"query" : "苏州",
"slop" : 0,
"boost" : 10000.0
}
}
},
"weight" : 1.0
}
],
"score_mode" : "sum",
"boost_mode" : "sum",
"max_boost" : 3.4028235E38,
"boost" : 1.0
}
}
}
2 个回复
core_wzw - 某AILab搜索技术负责人
赞同来自: dlliwei
我们知道filter不产生分数,纯召回而已,大家都是0/1。所以楼主你filter里的boost自然没生效,但为什么外层的weight生效了呢,因为这个filter放在function列表里,被当作一个query单元,weight作用在这个0/1单元上,给你产生weight可以作用在filter上的错觉。你试下把weight改成10,那么explain出来的这个function就是10分(10*1)。
liuxg - Elastic
赞同来自: