# How to use the high level rest API to build an Aggregation from JSON

**URL:** https://discuss.elastic.co/t/how-to-use-the-high-level-rest-api-to-build-an-aggregation-from-json/171981
**Category:** Elasticsearch
**Created:** [March 12, 2019, 2:43pm UTC](https://discuss.elastic.co/t/how-to-use-the-high-level-rest-api-to-build-an-aggregation-from-json/171981 "2019-03-12T14:43:13Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Bengagi\_Foued](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bengagi_foued/32/61961_2.png) [@Bengagi\_Foued](https://discuss.elastic.co/u/Bengagi_Foued)
#### Post date: [March 12, 2019, 2:43pm UTC](https://discuss.elastic.co/t/how-to-use-the-high-level-rest-api-to-build-an-aggregation-from-json/171981/1 "2019-03-12T14:43:14Z")

</div>

need help ! How to make the "set aggregation" from JSON string !  
I have an application where i build a json string with aggregations in frontend (angular) then i send this json to backend (Spring boot) to perform the request

---

<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: [March 12, 2019, 3:17pm UTC](https://discuss.elastic.co/t/how-to-use-the-high-level-rest-api-to-build-an-aggregation-from-json/171981/2 "2019-03-12T15:17:18Z")

</div>

May be read [How to use the ElasticSearch Java API to build an Aggregation from JSON](https://discuss.elastic.co/t/how-to-use-the-elasticsearch-java-api-to-build-an-aggregation-from-json/70773/6?u=dadoonet)

---

<div class="post-metadata">

### Author: ![Bengagi\_Foued](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bengagi_foued/32/61961_2.png) [@Bengagi\_Foued](https://discuss.elastic.co/u/Bengagi_Foued)
#### Post date: [March 12, 2019, 3:55pm UTC](https://discuss.elastic.co/t/how-to-use-the-high-level-rest-api-to-build-an-aggregation-from-json/171981/3 "2019-03-12T15:55:04Z")

</div>

is there a solution using elaticsearch high level rest api version 6.5 of elasticsearch ?

---

<div class="post-metadata">

### Author: ![Bengagi\_Foued](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bengagi_foued/32/61961_2.png) [@Bengagi\_Foued](https://discuss.elastic.co/u/Bengagi_Foued)
#### Post date: [March 12, 2019, 4:26pm UTC](https://discuss.elastic.co/t/how-to-use-the-high-level-rest-api-to-build-an-aggregation-from-json/171981/4 "2019-03-12T16:26:04Z")

</div>

i found the solution , using JestClientFactory .

```
 JestClientFactory factory = new JestClientFactory();
         HttpClientConfig httpClientConfig = new HttpClientConfig
                                     .Builder("http://localhost:9200")
                                     .build();
         factory.setHttpClientConfig(httpClientConfig);
         JestClient client = factory.getObject();
         Search.Builder searchBuilder = new Search.Builder(body)
 .addIndex(index); 

         SearchResult response = client.execute(searchBuilder.build());

         System.out.println(response.getJsonString());

         client.shutdownClient();
		return response.getJsonString();
```

---

<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: [April 9, 2019, 4:26pm UTC](https://discuss.elastic.co/t/how-to-use-the-high-level-rest-api-to-build-an-aggregation-from-json/171981/5 "2019-04-09T16:26:05Z")

</div>

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