我正在尝试使用以下查询在多匹配查询上创建自定义得分:
GET /product/_search
{
"custom_score": {
"query": {
"bool": {
"must": {
"multi_match" : {
"query": "casual shirt",
"type": "best_fields",
"fields": [ "brandTitle^15", "title^10", "details^5" ],
"tie_breaker": 1,
"fuzziness": "AUTO"
}
},
"filter": {
"term": {
"inStock": true
}
}
}
},
"params": {
"scoreWeighting": 2,
"popularityWeighting": 5
},
"script": "scoreWeighting * _score + popularityWeighting * doc['popularity'].value"
}
}
我尝试将参数,脚本和查询字段移动到不同的位置,以查看顺序在这里是否很重要(我假设不是,因为它是JSON对象)。该文档似乎也具有与我相似的语法: https://www.elastic.co/guide/en/elasticsearch/reference/0.90/query-dsl-custom-score-query.html,但我仍然没有运气。
我收到的错误是:
"Unknown key for a START_OBJECT in [custom_score]."
答案 0 :(得分:0)
根据以下内容,看来custom_score
已被弃用:
https://www.elastic.co/guide/en/elasticsearch/reference/0.90/query-dsl-custom-score-query.html
使用function_score_query
或script_score
这样的工具是正确的工具:
https://www.elastic.co/guide/en/elasticsearch/reference/0.90/query-dsl-function-score-query.html
此外,如果不建议过时,则custom_score必须位于查询中。