# Parent-Child model problem

**URL:** https://discuss.elastic.co/t/parent-child-model-problem/39356
**Category:** Elasticsearch
**Created:** [January 15, 2016, 8:05pm UTC](https://discuss.elastic.co/t/parent-child-model-problem/39356 "2016-01-15T20:05:58Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![cmk1523](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cmk1523/32/6474_2.png) [@cmk1523](https://discuss.elastic.co/u/cmk1523)
#### Post date: [January 15, 2016, 8:05pm UTC](https://discuss.elastic.co/t/parent-child-model-problem/39356/1 "2016-01-15T20:05:58Z")

</div>

With a parent-child relationship set up, I can accomplish certain questions like: I need all parents who have children of two different types. Perhaps I'd use "bool MUST" query with "child type A" and "child type B". If I aggregate on the parent ID field, I essentially get a list of unique parents that meet my query. That's all fine (if I can do that better, let me know).

The problem is what happens when I need a "bool MUST\_NOT" filter to be applied. For example, I want "child type A" and I don't want any parents whose children have ANY "type B". Why this fails is because there are one or more children of a certain type. For example, if parent has children of both type A and type B, my not filter will still return this parent.

The only model that works is a nested object whose nested object fields use the "include\_in\_parent" setting.

---

<div class="post-metadata">

### Author: ![Kevin\_Bourne](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kevin_bourne/32/53053_2.png) [@Kevin\_Bourne](https://discuss.elastic.co/u/Kevin_Bourne)
#### Post date: [September 30, 2016, 6:40pm UTC](https://discuss.elastic.co/t/parent-child-model-problem/39356/2 "2016-09-30T18:40:00Z")

</div>

I am having the same problem. Unfortunately similar questions on this forum have seem to go answer-less.

---

<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:15pm UTC](https://discuss.elastic.co/t/parent-child-model-problem/39356/3 "2017-07-05T22:15:45Z")

</div>


