# Get certain fields from children in has-child query

**URL:** <https://discuss.elastic.co/t/get-certain-fields-from-children-in-has-child-query/216031>\
**Category:** Elasticsearch\
**Created:** [January 22, 2020, 10:28am UTC](https://discuss.elastic.co/t/get-certain-fields-from-children-in-has-child-query/216031 "2020-01-22T10:28:03Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![johnkary](https://avatars.discourse-cdn.com/v4/letter/j/a9adbd/32.png) [@johnkary](https://discuss.elastic.co/u/johnkary)\
**Post date:** [January 22, 2020, 10:28am UTC](https://discuss.elastic.co/t/get-certain-fields-from-children-in-has-child-query/216031/1 "2020-01-22T10:28:03Z")

</div>

Hi all!  
I have an index with parent-child capability. I managed the **has-child** query to bring me specific fields from the parent with the command:

`_source": ["parent_field_1","parent_field_2"...]`

and it worked. Now i want to do the same for the children fields putting the same command again, but i receive the error message:

```
"type": "parsing_exception",
        "reason": "[has_child] query does not support [_source]",

```

My query:

```
GET npk/_search
    {
      "_source": ["parent_field_1","parent_field_2"...],
      "query": {
        "has_child": {
          "type": "body",
          "min_children": 1,
         "_source": ["child_field_1","child_field_2"...]
         "query": {
              "range": {
                 "child_field_1": {
                    "gte": 5,
                    "lte": 10
        } } },
       "inner_hits": {}
        } } }

```

How can i choose which fields from children i receive?

---

<div class="post-metadata">

**Author:** ![johnkary](https://avatars.discourse-cdn.com/v4/letter/j/a9adbd/32.png) [@johnkary](https://discuss.elastic.co/u/johnkary)\
**Post date:** [January 27, 2020, 10:29am UTC](https://discuss.elastic.co/t/get-certain-fields-from-children-in-has-child-query/216031/2 "2020-01-27T10:29:11Z")

</div>

Here i am again with a llittle bit answer! I just found the answer to my question. So, to define which fields i will get from children, i just put the `"_source": [child_field_3","child_field_4"` to "inner\_hits" at the and of the query, and voila!

So, this issue can be closed!

---

<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:** [February 24, 2020, 10:29am UTC](https://discuss.elastic.co/t/get-certain-fields-from-children-in-has-child-query/216031/3 "2020-02-24T10:29:17Z")

</div>

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