【发布时间】:2022-01-24 05:40:14
【问题描述】:
我最近将我的 ElasticSearch 版本从 5.3 版升级到了 5.6 版
"query" : {
"constant_score" : {
"query" : {
"bool" : {
"must" : {
"terms" : {
"customerId" : [ "ASERFE", "7004567457" ]
}
},
"must_not" : {
"terms" : {
"useCase" : [ "PAY", "COLLECT" ]
}
}
},
"bool" : {
"must" : {
"match" : {
"cardProductGroupName" : {
"query" : "Pre-fill Test birthday Present",
"type" : "phrase"
}
}
}
}
}
}
}
执行上面提到的查询给了我以下错误-
{"root_cause":[{"type":"parsing_exception","reason":"[constant_score] 查询不支持 [query]","line":1,"col":37}]," type":"parsing_exception","reason":"[constant_score] 查询不支持 [query]","line":1,"col":37}
所以,我搜索了解决方案并找到了这个 function_score 查询。在执行下面提到的查询时,我得到的结果与使用 constant_score 得到的结果相同。
"query" : {
"function_score" : {
"query" : {
"bool" : {
"must" : {
"terms" : {
"customerId" : [ "ASERFE", "7004567457" ]
}
},
"must_not" : {
"terms" : {
"useCase" : [ "PAY", "COLLECT" ]
}
}
},
"bool" : {
"must" : {
"match" : {
"groupName" : {
"query" : "Pre-fill Test birthday Present",
"type" : "phrase"
}
}
}
}
},
"functions" : [ {
"script_score" : {
"script" : "1"
}
} ],
"boost_mode" : "replace"
}
}
所以我的问题是,这是否意味着带有 script 的 function_score : "1" 会给出与 constant_function 相同的结果?
【问题讨论】:
标签: elasticsearch computer-science distributed-system aws-elasticsearch opensearch