# Which class and functions in Java code to use for Aggregation queries using Low Level Rest Client for elastic

**URL:** <https://discuss.elastic.co/t/which-class-and-functions-in-java-code-to-use-for-aggregation-queries-using-low-level-rest-client-for-elastic/253037>\
**Category:** Elasticsearch\
**Created:** [October 22, 2020, 3:51pm UTC](https://discuss.elastic.co/t/which-class-and-functions-in-java-code-to-use-for-aggregation-queries-using-low-level-rest-client-for-elastic/253037 "2020-10-22T15:51:46Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![daviddavid](https://avatars.discourse-cdn.com/v4/letter/d/a5b964/32.png) [@daviddavid](https://discuss.elastic.co/u/daviddavid)\
**Post date:** [October 22, 2020, 3:51pm UTC](https://discuss.elastic.co/t/which-class-and-functions-in-java-code-to-use-for-aggregation-queries-using-low-level-rest-client-for-elastic/253037/1 "2020-10-22T15:51:47Z")

</div>

Which class and functions in Java code to use for Aggregation queries using Low Level Rest Client for elastic. Which Class to be used. AggregationBuilder class seems to be not present in older version like in High Level Client.

Like for below body of rest call what is the way to write Java code for getting search response using low level client on elastic 5.6.10.  
{  
"aggs": {  
"total": { "sum": { "field": "accountbalance" } }  
}  
}

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [October 22, 2020, 7:40pm UTC](https://discuss.elastic.co/t/which-class-and-functions-in-java-code-to-use-for-aggregation-queries-using-low-level-rest-client-for-elastic/253037/2 "2020-10-22T19:40:38Z")

</div>

I'm afraid you have to do all this manually.

Best option IMO is to upgrade to 7.9.2.

---

<div class="post-metadata">

**Author:** ![daviddavid](https://avatars.discourse-cdn.com/v4/letter/d/a5b964/32.png) [@daviddavid](https://discuss.elastic.co/u/daviddavid)\
**Post date:** [October 23, 2020, 1:00am UTC](https://discuss.elastic.co/t/which-class-and-functions-in-java-code-to-use-for-aggregation-queries-using-low-level-rest-client-for-elastic/253037/3 "2020-10-23T01:00:17Z")

</div>

Did not get manually meaning. You mean it can be only done in browser search using \_search url only and not from java code.  
You mean with Java code there is no way to get Aggregate query search using RestClient in low level clients in older elastic version? Or there is some way or other.

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [October 23, 2020, 5:28am UTC](https://discuss.elastic.co/t/which-class-and-functions-in-java-code-to-use-for-aggregation-queries-using-low-level-rest-client-for-elastic/253037/4 "2020-10-23T05:28:08Z")

</div>

I meant that with the Low Level client, you need to build the request as a Json document (a `String` basically) and parse yourself the json response (a `String`).

---

<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:** [November 20, 2020, 5:28am UTC](https://discuss.elastic.co/t/which-class-and-functions-in-java-code-to-use-for-aggregation-queries-using-low-level-rest-client-for-elastic/253037/5 "2020-11-20T05:28:09Z")

</div>

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