# Parent-Child relationship using join

**URL:** <https://discuss.elastic.co/t/parent-child-relationship-using-join/107581>\
**Category:** Elasticsearch\
**Created:** [November 14, 2017, 4:08pm UTC](https://discuss.elastic.co/t/parent-child-relationship-using-join/107581 "2017-11-14T16:08:36Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![lele](https://avatars.discourse-cdn.com/v4/letter/l/e5b9ba/32.png) [@lele](https://discuss.elastic.co/u/lele)\
**Post date:** [November 14, 2017, 4:08pm UTC](https://discuss.elastic.co/t/parent-child-relationship-using-join/107581/1 "2017-11-14T16:08:36Z")

</div>

Hi everyone,  
I'm using ES 5.6 and I created an index with the single\_type setting set to true with a join field as the following:

```
"join_field": {
    "type": "join",
    "eager_global_ordinals": true,
    "relations": {
        "doc": "child"
    }
}

```

Now I want to perform a query on the parent document and to make an aggregation on a field in its child.  
With the previous version of ES I would do something like this:

```
{
  "query": {
    "has_parent": {
      "parent_type": "doc",
      "query": {
        "term": {
          "content": {
            "value": "a_word_to_search"
          }
        }
      }
    }
  }, 
  "aggs": {
    "name_1": {
       "terms": {
           "field": "child_field",
           "size": 2
       }
    }
  },
  "size": 0
}

```

The problem is that now, with the new join field, the has\_parent query does not work anymore.  
How can I perform the same query with the new ES features?

---

<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:** [December 12, 2017, 4:08pm UTC](https://discuss.elastic.co/t/parent-child-relationship-using-join/107581/2 "2017-12-12T16:08:57Z")

</div>

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