# Tutorials and Examples of Aggregations in the Java High Level Client

**URL:** <https://discuss.elastic.co/t/tutorials-and-examples-of-aggregations-in-the-java-high-level-client/248980>\
**Category:** Elasticsearch\
**Created:** [September 17, 2020, 12:57pm UTC](https://discuss.elastic.co/t/tutorials-and-examples-of-aggregations-in-the-java-high-level-client/248980 "2020-09-17T12:57:34Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![robshep](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/robshep/32/40343_2.png) [@robshep](https://discuss.elastic.co/u/robshep)\
**Post date:** [September 17, 2020, 12:57pm UTC](https://discuss.elastic.co/t/tutorials-and-examples-of-aggregations-in-the-java-high-level-client/248980/1 "2020-09-17T12:57:35Z")

</div>

Hi,

I'm looking for tutorials and examples of building aggregates using the Java High Level client API.  
Google doesn't throw up much, the ES guide is an overview of functionality and the Javadocs just list the API of course.

I'm interested in building bucketed queries of simple things like hourly mean of a field over a time range.

Whilst i can find JSON query samples, I'd like to find some more examples of constructing these using the HL API specifically.

Any pointers appreciated.

Thanks

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [September 17, 2020, 2:16pm UTC](https://discuss.elastic.co/t/tutorials-and-examples-of-aggregations-in-the-java-high-level-client/248980/3 "2020-09-17T14:16:25Z")

</div>

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](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](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

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [October 15, 2020, 2:16pm UTC](https://discuss.elastic.co/t/tutorials-and-examples-of-aggregations-in-the-java-high-level-client/248980/4 "2020-10-15T14:16:34Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
