gpt4 book ai didi

python - ElasticSearch错误:[function_score]格式错误的查询,预期[END_OBJECT],但发现[FIELD_NAME]

转载 作者:行者123 更新时间:2023-12-03 01:44:57 25 4
gpt4 key购买 nike

以下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(boolean) 查询本身可以完美运行,但是一旦我使用function_score,它就会停止工作。我尝试遵循以下示例: https://www.elastic.co/guide/en/elasticsearch/guide/master/boosting-by-popularity.html

关于我在做什么错的任何想法,将不胜感激!

最佳答案

您必须在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
}

关于python - ElasticSearch错误:[function_score]格式错误的查询,预期[END_OBJECT],但发现[FIELD_NAME],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44788945/

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