Hi Team,
I have a requirement where I have to put a flag as True or False if my parent record has child records exists in the elastic index. For this purpose I am making use of scripted field but I guess I cannot use it within should clause.
Below is my query that I have created. I am not sure where I am going wrong.
POST players/_search
{
"query": {
"bool": {
"should": [
{
"has_child": {
"type": "club",
"query": {
"bool": {
"must": [
{
"match_all": {}
}
]
}
}
},
"script_fields": {
"inClub": {
"script": "true"
}
}
}
]
}
}
}
}
}
I got the below response.
{
"error": {
"root_cause": [
{
"type": "parsing_exception",
"reason": "[has_child] malformed query, expected [END_OBJECT] but found [FIELD_NAME]",
"line": 18,
"col": 11
}
],
"type": "parsing_exception",
"reason": "[has_child] malformed query, expected [END_OBJECT] but found [FIELD_NAME]",
"line": 18,
"col": 11
},
"status": 400
}
Any light on this will be helpful.
Thanks,