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?