# How to query parent with no children

**URL:** <https://discuss.elastic.co/t/how-to-query-parent-with-no-children/56988>\
**Category:** Elasticsearch\
**Created:** [August 2, 2016, 10:00am UTC](https://discuss.elastic.co/t/how-to-query-parent-with-no-children/56988 "2016-08-02T10:00:33Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Keith\_Garrod](https://avatars.discourse-cdn.com/v4/letter/k/59ef9b/32.png) [@Keith\_Garrod](https://discuss.elastic.co/u/Keith_Garrod)\
**Post date:** [August 2, 2016, 10:00am UTC](https://discuss.elastic.co/t/how-to-query-parent-with-no-children/56988/1 "2016-08-02T10:00:33Z")

</div>

I have a parent document with optional children.

I want to find all parents with NO (0) children.

It seems the only way to query children is the 'has\_child' filter. I have tried setting min\_children and max\_children to 0 but I don't get the results I want.

Any suggestions please?

---

<div class="post-metadata">

**Author:** ![Taras\_Kohut](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/taras_kohut/32/12118_2.png) [@Taras\_Kohut](https://discuss.elastic.co/u/Taras_Kohut)\
**Post date:** [June 10, 2017, 3:18pm UTC](https://discuss.elastic.co/t/how-to-query-parent-with-no-children/56988/2 "2017-06-10T15:18:43Z")

</div>

This Stack Overflow answer should help:

> <https://stackoverflow.com/questions/41283486/elasticsearch-get-all-parents-with-no-children/41285084#41285084>

---

<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:** [November 4, 2022, 4:25am UTC](https://discuss.elastic.co/t/how-to-query-parent-with-no-children/56988/3 "2022-11-04T04:25:41Z")

</div>


