以下JSON结构在执行查询时出错:
{
"query": {
"function_score": {
"query": {
"bool": {
"should": [
{
"multi_match": {
"query": "BRCA1",
"fuzziness": "AUTO",
"fields": [
"Long_Name",
"Short_Name",
"Uniprot_ID^10",
"Genes^2",
"Diseases^2",
"Function",
"Domains"
]
}
},
{
"term": {
"Is_Reviewed": true
}
},
{
"term": {
"Has_Function": true
}
}
]
}
}
},
"field_value_factor": {
"field": "Number_Of_Structures"
}
},
"size": 100
}
错误是:
[function_score] malformed query, expected [END_OBJECT] but found [FIELD_NAME]
bool查询本身可以很好地工作,但是一旦我使用function_score,它就会停止工作。我试图效仿这个例子:https://www.elastic.co/guide/en/elasticsearch/guide/master/boosting-by-popularity.html
我非常感谢任何关于我做错事的想法!
答案 0 :(得分:1)
您必须在field_value_factor
:
function_score
提高一级
{
"query": {
"function_score": {
"query": {
"bool": {
"should": [
{
"multi_match": {
"query": "BRCA1",
"fuzziness": "AUTO",
"fields": [
"Long_Name",
"Short_Name",
"Uniprot_ID^10",
"Genes^2",
"Diseases^2",
"Function",
"Domains"
]
}
},
{
"term": {
"Is_Reviewed": true
}
},
{
"term": {
"Has_Function": true
}
}
]
}
},
"field_value_factor": {
"field": "Number_Of_Structures"
}
}
},
"size": 100
}