【发布时间】:2019-01-03 22:53:14
【问题描述】:
我需要一个执行以下操作的查询:
- 过滤文档
- 地理距离得分
- 使用增强模式“倍增”(这是默认设置)
我稍微简化了我的真实查询来演示它:
"query": {
"function_score": {
"query": {
"bool": {
"must": [],
"filter": {
"bool": {
"must": [
{
"term": {
"is_good": true
}
}
// here could be another filter
]
}
}
}
},
"functions": [
{
"linear": {
"locations.geo_point": {
"origin": {
"lat": 52.518611,
"lon": 13.408333
},
"offset": "3km",
"scale": "15km"
}
}
}
]
}
}
问题:每个文档的分数都是0。
解释来自elasticsearch:
"_explanation": {
"value": 0,
"description": "function score, product of:",
"details": [
{
"value": 0,
"description": "ConstantScore(is_good:T)^0.0",
"details": []
},
{
"value": 1,
"description": "min of:",
"details": [
{
"value": 1,
"description": "Function for field locations.geo_point:",
"details": [
{
"value": 1,
"description": "max(0.0, ((30000.0 - MIN of: [0.0])/30000.0)",
"details": []
}
]
},
{
"value": 3.4028235e+38,
"description": "maxBoost",
"details": []
}
]
}
]
}
您会看到,术语过滤器的分数为 0。通过乘法,总分变为 0。我一直试图给术语过滤器评分 1 或以某种方式摆脱它对分数的影响,但是没有找到有效的解决方案。所以我想,查询必须进行大量重组,但是如何?
【问题讨论】:
-
过滤器不计算分数,所以它总是为零。
标签: elasticsearch