Aggregration through Java High Level Rest Client

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.

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

Thanks.

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