Hey,
I think your best bet is to look at the AggregationBuilders class in combination with the high level rest client reference documentation, i.e. https://www.elastic.co/guide/en/elasticsearch/client/java-rest/7.8/java-rest-high-aggregation-builders.html
Another great resource of learning are the tests (that are used to generate the documentation), see https://github.com/elastic/elasticsearch/blob/master/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/SearchDocumentationIT.java
If there is any more concrete question, feel free to ask!
hope that helps!
--Alex