I want to run query using python elasticsearch client
GET /employee-index/_search
{
"size":0,
"aggs": {
"genres": {
"terms": { "field": "gender.keyword" }
}
}
}
This is what I am doing but it is returning me the records
es = Elasticsearch()
s = Search(using=es, index="employee-index").aggs.bucket('gender', 'terms', field='gender.keyword')
s = s.execute()
print (s)
It I look at the query running to ES it only has aggs count. I couldn't find in the documentation how to set size to 0 for returning only the aggregation. I try setting but it doesn't work.
Search(using=es, index="employee-index").aggs.bucket('gender', 'terms', field='gender.keyword', size=0)