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

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

May be read How to use the ElasticSearch Java API to build an Aggregation from JSON

1 Like

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

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();

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