Includes fields in top hits aggregation

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?

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