SearchQuery searchQuery = new NativeSearchQueryBuilder()
.withIndices("myindex2","myindex4") //可以直接使用别名
.withQuery(queryBuilder)
//.addAggregation(sumBuilder)
.build();
List<Map> map=elasticsearchTemplate.query(searchQuery, response -> {
SearchHits hits = response.getHits();
List<Map> list=new ArrayList<>();
Arrays.stream(hits.getHits()).forEach(h -> {
Map<String, Object> source = h.getSource();
System.out.println(JSONArray.toJSONString(source));
list.add(source);
return list;