Has_child not working as expected inside has_parent

I have a parent child relationship in my elasticsearch 7.9 where I am having the car as a parent type and it has multiple child types like honda, suzuki, volvo now I want to have a child of type volvo and parent type is car.

{
    "query": {
        "has_parent": {
            "parent_type": "car",
            "query": {
                "has_child": {
                    "type": "volvo",
                    "query": {
                        "match_all":{}
                    }
                }
            }
        }
    }
}

It is returning the objects having child type honda as well.
Where I am wrong ?
Thanks.

  • what should be the query where I want the parent_type car with an id xxxxx and child is volvo.
1 Like

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.