# How can I use elasticsearch java aip to agg from the Query Builders？

**URL:** https://discuss.elastic.co/t/how-can-i-use-elasticsearch-java-aip-to-agg-from-the-query-builders/259624
**Category:** Elasticsearch
**Created:** [December 25, 2020, 9:00am UTC](https://discuss.elastic.co/t/how-can-i-use-elasticsearch-java-aip-to-agg-from-the-query-builders/259624 "2020-12-25T09:00:32Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Vastzhang](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vastzhang/32/81393_2.png) [@Vastzhang](https://discuss.elastic.co/u/Vastzhang)
#### Post date: [December 25, 2020, 9:00am UTC](https://discuss.elastic.co/t/how-can-i-use-elasticsearch-java-aip-to-agg-from-the-query-builders/259624/1 "2020-12-25T09:00:32Z")

</div>

Hi!I use elasticsearch java api like as follw:

 ![1](https://us1.discourse-cdn.com/elastic/original/3X/3/6/3675f3e81652a5fcb96d478901c05445d98aa268.png)  
how can i convert json as follow to java api？  
 ![2](https://us1.discourse-cdn.com/elastic/original/3X/a/2/a203a85b1b5146313375663506dd00c2209ddc04.png)  
Thanks！！！

---

<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: [December 25, 2020, 10:15am UTC](https://discuss.elastic.co/t/how-can-i-use-elasticsearch-java-aip-to-agg-from-the-query-builders/259624/2 "2020-12-25T10:15:23Z")

</div>

Please don't post images of text as they are hard to read, may not display correctly for everyone, and are not searchable.

Instead, paste the text and format it with `</>` icon or pairs of triple backticks (```), and check the preview window to make sure it's properly formatted before posting it. This makes it more likely that your question will receive a useful answer.

It would be great if you could update your post to solve this.

---

<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: [December 25, 2020, 10:18am UTC](https://discuss.elastic.co/t/how-can-i-use-elasticsearch-java-aip-to-agg-from-the-query-builders/259624/3 "2020-12-25T10:18:19Z")

</div>

You can look at :

> **[Building Aggregations | Java REST Client \[7.10\] | Elastic](https://www.elastic.co/guide/en/elasticsearch/client/java-rest/current/java-rest-high-aggregation-builders.html)**

I do have some examples at:

> <https://github.com/dadoonet/legacy-search/blob/80441a5926979a6f20b75ad037cddf90ff64a51e/src/main/java/fr/pilato/demo/legacysearch/dao/ElasticsearchDao.java#L126-L128>

---

<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: [January 22, 2021, 10:18am UTC](https://discuss.elastic.co/t/how-can-i-use-elasticsearch-java-aip-to-agg-from-the-query-builders/259624/4 "2021-01-22T10:18:23Z")

</div>

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