# How to write inner\_hits for my nested query?

**URL:** <https://discuss.elastic.co/t/how-to-write-inner-hits-for-my-nested-query/86679>\
**Category:** Elasticsearch\
**Created:** [May 22, 2017, 2:00pm UTC](https://discuss.elastic.co/t/how-to-write-inner-hits-for-my-nested-query/86679 "2017-05-22T14:00:06Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![maralbe](https://avatars.discourse-cdn.com/v4/letter/m/6f9a4e/32.png) [@maralbe](https://discuss.elastic.co/u/maralbe)\
**Post date:** [May 22, 2017, 2:00pm UTC](https://discuss.elastic.co/t/how-to-write-inner-hits-for-my-nested-query/86679/1 "2017-05-22T14:00:06Z")

</div>

i have created a mapping like this :  
'mappings' =\> [

```
            'my_type' => [
                'properties' => [
                    'folder_applications' => [
                        'type' => 'nested',
                        "properties" => [
                            "folder" => [
                                "type" => "nested",
                                "properties" => [
                                    "employer_id" => [
                                        "type" => "long"
                                    ],
                                    "id" => [
                                        "type" => "long"
                                    ]
                                ]
                            ],
                            "hire_stage_id" => [
                                "type" => "long"
                            ],
                            "is_applied" => [
                                "type" => "long"
                            ],
                            "status_id" => [
                                "type" => "long"
                            ]
                        ]
                    ],

                ]
            ]
        ]

```

my question is how can i write nested inner\_hits for this?  
for example i want search in folder for "id" field and in folder\_applications for "status\_id" field..

i tried many ways and search in documents and read other user problems.. but i couldn't write my own..

can anyone help me in this?

thanks with advanced.

---

<div class="post-metadata">

**Author:** ![Clinton\_Gormley](https://avatars.discourse-cdn.com/v4/letter/c/50afbb/32.png) [@Clinton\_Gormley](https://discuss.elastic.co/u/Clinton_Gormley)\
**Post date:** [May 26, 2017, 8:30am UTC](https://discuss.elastic.co/t/how-to-write-inner-hits-for-my-nested-query/86679/2 "2017-05-26T08:30:15Z")

</div>

You need to be clearer about what you are asking, and make it easier to answer.

Provide a recreation of what you are doing that can be copied and pasted into the Console, to create the index, index some documents, and then show what query you are trying. Explain why your query isn't doing what you want, and explain exactly what you are trying to achieve.

Without this information, nobody is likely to answer

---

<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:** [June 23, 2017, 8:30am UTC](https://discuss.elastic.co/t/how-to-write-inner-hits-for-my-nested-query/86679/3 "2017-06-23T08:30:57Z")

</div>

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