gpt4 book ai didi

node.js - constant_score查询不支持在代码中查询

转载 作者:搜寻专家 更新时间:2023-10-31 23:39:43 25 4
gpt4 key购买 nike

当我尝试运行以下代码时出现“constant score query doesn't support query”错误。

client.search({
index: ['index1','index2'],
body: {
from: 0, size: 20,
query: {
"constant_score": {
boost: 1.0,
"query": {
query_string: {
query: str,
fields: ['field_1']
}
}
}
}
},
});

最佳答案

constant_score 查询包装另一个查询。它接受另一个 queryfilter 。将 query_string 包装在 filter 而不是 query 中。

尝试使用以下方法:

client.search({
index: ['index1','index2'],
body: {
from: 0, size: 20,
query: {
"constant_score": {
boost: 1.0,
filter: {
query_string: {
query: str,
fields: ['field_1']
}
}
}
}
},
});

关于node.js - constant_score查询不支持在代码中查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54710986/

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