A.C*_*Ran 3 node.js elasticsearch
当我尝试运行以下代码时,会出现“恒定分数查询不支持查询”错误。
client.search({
index: ['index1','index2'],
body: {
from: 0, size: 20,
query: {
"constant_score": {
boost: 1.0,
"query": {
query_string: {
query: str,
fields: ['field_1']
}
}
}
}
},
});
Run Code Online (Sandbox Code Playgroud)
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']
}
}
}
}
},
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1018 次 |
| 最近记录: |