Reputation: 628
I've been trying to run the following query, but every time I run it I receive the following error:
nested: ElasticsearchParseException[Expected field name but got START_OBJECT \"field_value_factor\"]; }]","status":400
Here is the query:
{
"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"
}
}
}
Upvotes: 3
Views: 7842
Reputation: 966
You have an error in your query, field_value_factor
is n attribute of function_score:
{
"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"
}
}
}
}
since you have a single function, you don't need to nest this into "functions"
Upvotes: 0
Reputation: 217304
Your field_value_factor
function is misplaced. it should be nested within the functions
property. Try this query instead
{
"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": {}
}
}
]
}
}
}
}
}
Upvotes: 2