Aggregration through Java High Level Rest Client


(Teddy) #1

I need to perform aggregations on multiple index through Java.

RestHighLevelClient client = new RestHighLevelClient(RestClient.builder(new HttpHost("localhost",9200,"http")));
		
		SearchRequest searchRequest = new SearchRequest();
		SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
		searchSourceBuilder.query(QueryBuilders.matchAllQuery()).aggregation(AggregationBuilders.avg("expenditure_avg").field("expenditure"));
		searchRequest.source(searchSourceBuilder);
		SearchResponse searchResponse = client.search(searchRequest);
	
		
		System.out.println(searchResponse.toString());

I have tried the above but dont know how to perform the same on multiple Index.


(David Pilato) #2

From the code you pasted, you are already running that on all indices.


(Teddy) #3

Thanks.


(system) #4

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