我一直在尝试运行以下查询,但是每次运行它时,都会收到以下错误:
nested: ElasticsearchParseException[Expected field name but got START_OBJECT \"field_value_factor\"]; }]","status":400
这是查询:
{ "query": { "function_score": { "query": { "bool": { "should": [{ "match": { "thread_name": "parenting" } }, { "nested": { "path": "messages", "query": { "bool": { "should": [{ "match": { "messages.message_text": "parenting" } }] } }, "inner_hits": {} } }] } } }, "field_value_factor": { "field": "thread_view" } } }
您的field_value_factor功能放错了位置。它应该嵌套在functions属性中。试试这个查询
field_value_factor
functions
{ "query": { "function_score": { "functions": [ { "field_value_factor": { "field": "thread_view" } } ], "query": { "bool": { "should": [ { "match": { "thread_name": "parenting" } }, { "nested": { "path": "messages", "query": { "bool": { "should": [ { "match": { "messages.message_text": "parenting" } } ] } }, "inner_hits": {} } } ] } } } } }