我一直在尝试运行以下查询,但每次运行它时都会收到以下错误:
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"
}
}
}
答案 0 :(得分:2)
您的field_value_factor
功能放错了地方。它应该是nested within the functions
property。请尝试此查询
{
"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": {}
}
}
]
}
}
}
}
}
答案 1 :(得分:0)
您的查询中有错误,field_value_factor
是function_score的n属性:
{
"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"
}
}
}
}
由于您只有一个功能,因此您无需将其嵌入"功能"