# Has\_child not working as expected inside has\_parent

**URL:** <https://discuss.elastic.co/t/has-child-not-working-as-expected-inside-has-parent/259992>\
**Category:** Elasticsearch\
**Created:** [January 1, 2021, 12:11pm UTC](https://discuss.elastic.co/t/has-child-not-working-as-expected-inside-has-parent/259992 "2021-01-01T12:11:35Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Waseem\_Farooqui](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/waseem_farooqui/32/79527_2.png) [@Waseem\_Farooqui](https://discuss.elastic.co/u/Waseem_Farooqui)\
**Post date:** [January 1, 2021, 12:11pm UTC](https://discuss.elastic.co/t/has-child-not-working-as-expected-inside-has-parent/259992/1 "2021-01-01T12:11:35Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [January 29, 2021, 12:11pm UTC](https://discuss.elastic.co/t/has-child-not-working-as-expected-inside-has-parent/259992/2 "2021-01-29T12:11:45Z")

</div>

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