Group by Terms my_field.keyword

Common problem when upgrading to Elasticsearch 5.x. Answered here:

So check your mapping to see if you have a keyword index mapping that you can use otherwise you will have to create it.