# Includes fields in top hits aggregation

**URL:** <https://discuss.elastic.co/t/includes-fields-in-top-hits-aggregation/79667>\
**Category:** Elasticsearch\
**Created:** [March 23, 2017, 2:02am UTC](https://discuss.elastic.co/t/includes-fields-in-top-hits-aggregation/79667 "2017-03-23T02:02:29Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Khoa\_Nguyen1](https://avatars.discourse-cdn.com/v4/letter/k/dec6dc/32.png) [@Khoa\_Nguyen1](https://discuss.elastic.co/u/Khoa_Nguyen1)\
**Post date:** [March 23, 2017, 2:02am UTC](https://discuss.elastic.co/t/includes-fields-in-top-hits-aggregation/79667/1 "2017-03-23T02:02:29Z")

</div>

I have the following query to group the top N users by geo-grid:

> POST user-listing/\_search  
> {  
> "size": 0,  
> "query": {  
> "function\_score": {  
> "query": {  
> "match\_all": {}  
> },  
> "random\_score": {}  
> }  
> },  
> "aggs": {  
> "group\_by\_location": {  
> "geohash\_grid": {  
> "field": "location",  
> "precision": 4  
> },  
> "aggs": {  
> "users": {  
> "top\_hits": {  
> "size": 100  
> }  
> }  
> }  
> }  
> }  
> }

However, I don't want to return the whole record of each user, just the "email" field. I tried to use "includes" and/or "excludes" but couldn't get it to work. Any suggestions?

---

<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:** [April 20, 2017, 2:02am UTC](https://discuss.elastic.co/t/includes-fields-in-top-hits-aggregation/79667/2 "2017-04-20T02:02:49Z")

</div>

Closed on April 20, 2017, 2:02am UTC

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