我试图将bool搜索与功能结合起来。但我无法弄明白。它给了我一个错误:没有为[functions_score]注册查询。
因此,无法找到将functions_score应用于的查询。任何想法,任何人?谢谢!
"body": {
"query": {
"functions_score": {
"query": {
"bool": {
"must": [
{
"query_string": {
"fields": [
"title",
"description"
],
"query": "zalan*",
"analyzer": "default",
"default_operator": "AND"
}
},
{
"range": {
"from": {
"lt": 1432201614
}
}
}
],
"should": [
{
"range": {
"to": {
"gt": 1432201614
}
}
},
{
"constant_score": {
"filter": {
"missing": {
"field": "to"
}
}
}
}
],
"minimum_should_match": 1
}
},
"functions": [
{
"boost_factor": 2
},
{
"field_value_factor": {
"field": "number_of_clicks",
"factor": 1.1,
"modifier": "sqrt"
}
},
{
"field_value_factor": {
"field": "webshop_popular",
"factor": 10,
"modifier": "sqrt"
}
}
]
}
},
"size": 20,
"sort": [
{
"webshop_popular": {
"order": "desc",
"mode": "avg"
}
},
{
"type": {
"order": "asc",
"mode": "avg"
}
}
]
}
答案 0 :(得分:2)
上述查询dsl中存在拼写错误,function_score而不是functions_score
同样来自OP中的查询看起来不像你使用得分来排序结果,在这种情况下使用函数是多余的