Elasticsearch documentation suggests* that their piece of code
*documentation fixed
GET /cars/transactions/_search?search_type=
To update the excellent answer from Andrei Stefan, we need to say that the query parameter search_type=count is no more supported in Elasticsearch 5. The new way of doing this is to add "size" : 0 in the body such as :
GET /cars/transactions/_search
{
"size": 0,
"aggs": {
"distinct_colors": {
"terms": {
"field": "color",
"size": 1000
}
}
}
}