# Inner Hits including parent document

**URL:** <https://discuss.elastic.co/t/inner-hits-including-parent-document/100765>\
**Category:** Elasticsearch\
**Created:** [September 16, 2017, 2:13pm UTC](https://discuss.elastic.co/t/inner-hits-including-parent-document/100765 "2017-09-16T14:13:33Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![visitek](https://avatars.discourse-cdn.com/v4/letter/v/9d8465/32.png) [@visitek](https://discuss.elastic.co/u/visitek)\
**Post date:** [September 16, 2017, 2:13pm UTC](https://discuss.elastic.co/t/inner-hits-including-parent-document/100765/1 "2017-09-16T14:13:33Z")

</div>

Is there possible to get work something like this? I've tried inner\_hits also from parent to child, but still no effect.  
ES 5.6  
I thing, something is disabled, because inner\_hits are not applied. I can not find whats wrong.  
Mappings has \_parent and documents are indexed with reference to parent. It works, because has\_parent and has\_child filter works as expected.

Whats wrong with inner hits? 😕

```auto
{
  "index": "??",
  "size": 1,
  "body": {
    "query": {
      "has_parent": {
        "parent_type": "Parent",
        "inner_hits": {
          "name": "NameOfHits"
        }
      }
    }
  }
}

```

---

<div class="post-metadata">

**Author:** ![mvg](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mvg/32/98890_2.png) [@mvg](https://discuss.elastic.co/u/mvg)\
**Post date:** [September 22, 2017, 8:05am UTC](https://discuss.elastic.co/t/inner-hits-including-parent-document/100765/2 "2017-09-22T08:05:02Z")

</div>

That should work. Can you share your mappings?

---

<div class="post-metadata">

**Author:** ![visitek](https://avatars.discourse-cdn.com/v4/letter/v/9d8465/32.png) [@visitek](https://discuss.elastic.co/u/visitek)\
**Post date:** [October 10, 2017, 2:31pm UTC](https://discuss.elastic.co/t/inner-hits-including-parent-document/100765/3 "2017-10-10T14:31:28Z")

</div>

Just simply set \_parent mappings for child documents. Childs are indexed with parent ID value

```php
'TicketFlow' => [
    '_parent' => [
        'type' => 'Ticket',
    ],
    '_routing' => [
        'required' => true,
    ],
    'properties' => [...]
],

```

---

<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:** [November 7, 2017, 2:31pm UTC](https://discuss.elastic.co/t/inner-hits-including-parent-document/100765/4 "2017-11-07T14:31:29Z")

</div>

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