You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
custom_score query within has_child query does not recognize child document fields within the score script.
I have two document types, "Forums" and "ForumStats". Forums is a parent type and ForumStats is a child type. I had set the mapping correctly.
When I issue query like the one below on forums type, ES complains that the field "avgPostsPerMinute" is not found in "Forums" type, which I feel is wrong as the script is supposed to look at child document fields.
Note: "avgPostsPerMinute" field belongs to ForumStats type.
If I set the script to a value that doe snot refer to child document type, then the query runs and I get a score for the parent document correctly.
Please review this and let me know if this is by design or a bug. If it is by design, it looks odd as the custom score query is running on child documents and I would expect ES to recognize the child document fields within the script property.
Thanks & Regards,
Aditya.
The text was updated successfully, but these errors were encountered:
@apasumarthi this is known issue. The script in the custom_score query inside has_child is working in context of the parent query. So, you need to use fully qualified field names:
custom_score query within has_child query does not recognize child document fields within the score script.
I have two document types, "Forums" and "ForumStats". Forums is a parent type and ForumStats is a child type. I had set the mapping correctly.
When I issue query like the one below on forums type, ES complains that the field "avgPostsPerMinute" is not found in "Forums" type, which I feel is wrong as the script is supposed to look at child document fields.
Note: "avgPostsPerMinute" field belongs to ForumStats type.
{
"size": 20,
"sort": {
"_score": "desc"
},
"query": {
"has_child": {
"type": "forumstats",
"score_type": "sum",
"query": {
"custom_score": {
"script": "doc['avgPostsPerMin'].value",
"query": {
"match_all": {}
}
}
}
}
}
}
If I set the script to a value that doe snot refer to child document type, then the query runs and I get a score for the parent document correctly.
Please review this and let me know if this is by design or a bug. If it is by design, it looks odd as the custom score query is running on child documents and I would expect ES to recognize the child document fields within the script property.
Thanks & Regards,
Aditya.
The text was updated successfully, but these errors were encountered: