gpt4 book ai didi

elasticsearch - Rescore是否支持嵌套查询?

转载 作者:行者123 更新时间:2023-12-03 01:07:22 28 4
gpt4 key购买 nike

我正在尝试使用嵌套查询对查询结果进行重新评分,但是出现以下异常,我认为这意味着重新评分不支持嵌套查询:

nested: ElasticsearchIllegalArgumentException[rescore doesn't support [path]];

是这样吗 ?

嵌套的对象包含应匹配的键字段和应用作分数的权重字段。这是查询:
POST myindex/_search
{
"query" : {
"match" : {
"field1" : {
"query" : "my_query_string",
"type" : "boolean"
}
}
},
"rescore" : {
"window_size" : 50,
"query": {
"nested": {
"path": "path.to.nested.object",
"score_mode" : "avg",
"query": {
"function_score": {
"query":{
"constant_score": {
"query": {
"match": {
"path.to.nested.object.key": "my_query_string"
}
}
}
},
"script_score": {
"script": "doc['path.to.nested.object.weight'].value"
}
}
}
}
}
}
}

最佳答案

查询中存在语法错误使用重新评分,您需要使用rescore_query,因为query_rescorer是当前唯一受支持的实现。

以下应该工作:

POST myindex/_search
{
"query": {
"match": {
"field1": {
"query": "my_query_string",
"type": "boolean"
}
}
},
"rescore": {
"window_size": 50,
"query": {
"rescore_query": {
"nested": {
"path": "path.to.nested.object",
"score_mode": "avg",
"query": {
"function_score": {
"query": {
"constant_score": {
"query": {
"match": {
"path.to.nested.object.key": "my_query_string"
}
}
}
},
"script_score": {
"script": "doc['path.to.nested.object.weight'].value"
}
}
}
}
}
}
}
}

关于elasticsearch - Rescore是否支持嵌套查询?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25913225/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com