当我尝试运行以下代码时出现“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
查询包装另一个查询。它接受另一个 query
或 filter
。将 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/