# Max\_children,0 does not appear to work in has\_child filter?

**URL:** <https://discuss.elastic.co/t/max-children-0-does-not-appear-to-work-in-has-child-filter/38065>\
**Category:** Elasticsearch\
**Created:** [December 28, 2015, 5:06pm UTC](https://discuss.elastic.co/t/max-children-0-does-not-appear-to-work-in-has-child-filter/38065 "2015-12-28T17:06:20Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![bw99](https://avatars.discourse-cdn.com/v4/letter/b/e9a140/32.png) [@bw99](https://discuss.elastic.co/u/bw99)\
**Post date:** [December 28, 2015, 5:06pm UTC](https://discuss.elastic.co/t/max-children-0-does-not-appear-to-work-in-has-child-filter/38065/1 "2015-12-28T17:06:21Z")

</div>

I want to be able to select parents that don't have any children matching a particular set of criteria. I thought that if I did:

```
        {
          "has_child": {
            "max_children": 0,
            "type": "event",
            "filter": {
              "bool": {
                "must": [
                  {
                    "bool": {
                      "must": [
                        {
                          "term": {
                            "cs_e": "eventF"
                          }
                        }
                      ],
                      "should": [],
                      "mustNot": []
                    }
                  }
                ],
                "should": [],
                "mustNot": []
              }
            }
          }
        }

```

then this would return me parents who had a maximum of 0 children - ie the parents that don't match. Curiously, however, I do get one parent back from the query, and that parent has one child that matches.

Is this expected? (Possibly I have messed up somewhere or misunderstood)?

Many thanks!

---

<div class="post-metadata">

**Author:** ![tbeuthel](https://avatars.discourse-cdn.com/v4/letter/t/f04885/32.png) [@tbeuthel](https://discuss.elastic.co/u/tbeuthel)\
**Post date:** [October 5, 2016, 2:26pm UTC](https://discuss.elastic.co/t/max-children-0-does-not-appear-to-work-in-has-child-filter/38065/2 "2016-10-05T14:26:47Z")

</div>

Hey there -\> did you ever get an answer to this question? I am running into the same issue

---

<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:** [July 5, 2017, 10:14pm UTC](https://discuss.elastic.co/t/max-children-0-does-not-appear-to-work-in-has-child-filter/38065/3 "2017-07-05T22:14:42Z")

</div>


