Get certain fields from children in has-child query

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?

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!

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