# Remove unnecessary elements from result for inner hits

**URL:** https://discuss.elastic.co/t/remove-unnecessary-elements-from-result-for-inner-hits/110938
**Category:** Elasticsearch
**Created:** [December 9, 2017, 4:56pm UTC](https://discuss.elastic.co/t/remove-unnecessary-elements-from-result-for-inner-hits/110938 "2017-12-09T16:56:32Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![morphers82](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/morphers82/32/22904_2.png) [@morphers82](https://discuss.elastic.co/u/morphers82)
#### Post date: [December 9, 2017, 4:56pm UTC](https://discuss.elastic.co/t/remove-unnecessary-elements-from-result-for-inner-hits/110938/1 "2017-12-09T16:56:32Z")

</div>

From this inner hits search result I'd like to only get the source of the inner hits,  
and not include the nested fields section for each hit( just before the score), because if there are numerous inner hits, including that same fields section would introduce a lot of extra data i don't need.  
How?

{  
"hits": {  
"total": 1,  
"max\_score": 0.6931472,  
"hits": [  
{  
"\_index": "test",  
"\_type": "doc",  
"\_id": "1",  
"\_score": 0.6931472,  
"\_source": ...,  
"inner\_hits": {  
"comments.votes": {  
"hits": {  
"total": 1,  
"max\_score": 0.6931472,  
"hits": [  
{  
// remove this next section between comments  
"\_nested": {  
"field": "comments",  
"offset": 1,  
"\_nested": {  
"field": "votes",  
"offset": 0  
}  
},  
//

```
              "_score": 0.6931472,
              "_source": {
                "value": 1,
                "voter": "kimchy"
              }
            }
          ]
        }
      }
    }
  }
]

```

}  
}

part I don't need in inner\_hits.hits.hits section

```
              "_nested": {
                "field": "comments",
                "offset": 1,
                "_nested": {
                  "field": "votes",
                  "offset": 0
                }
              }
```

---

<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: [January 6, 2018, 4:56pm UTC](https://discuss.elastic.co/t/remove-unnecessary-elements-from-result-for-inner-hits/110938/2 "2018-01-06T16:56:37Z")

</div>

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