# Returning Child and Grandparent without parent... ie flattening

**URL:** <https://discuss.elastic.co/t/returning-child-and-grandparent-without-parent-ie-flattening/55259>\
**Category:** Elasticsearch\
**Created:** [July 12, 2016, 3:20am UTC](https://discuss.elastic.co/t/returning-child-and-grandparent-without-parent-ie-flattening/55259 "2016-07-12T03:20:39Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mightyschwartz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mightyschwartz/32/10007_2.png) [@mightyschwartz](https://discuss.elastic.co/u/mightyschwartz)\
**Post date:** [July 12, 2016, 3:20am UTC](https://discuss.elastic.co/t/returning-child-and-grandparent-without-parent-ie-flattening/55259/1 "2016-07-12T03:20:39Z")

</div>

Has anyone been able to return the granchild and grandparent record without the parent returned as well?

I have the following which returns all 3. However, I'd like to return A and C from a hierarchy like A=\>B=\>C.

```
{
  "query" : {
    "has_child" : {
      "query" : {
        "has_child" : {
          "query" : {
            "match_all" : {}
          },
          "child_type" : "grandchild"
        }
      },
      "child_type" : "child"
    }
  },
  "inner_hits" : {
    "child" : {
      "type" : {
        "child" : {
          "inner_hits" : {
            "child" : {
              "type" : {
                "grandchild" : {}
              }
            }
          }
        }
      }
    }
  }
}
```

---

<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:36pm UTC](https://discuss.elastic.co/t/returning-child-and-grandparent-without-parent-ie-flattening/55259/2 "2017-07-05T22:36:21Z")

</div>


