我是弹性搜索的新手,我正在尝试使用聚合(min,max,avg,sum,count)来“分组”,我正在使用elasticsearch 1.3.1,列名和值即将到来来自DB,现在手动创建对象。
我陷入无限循环可以帮助任何人?这是我的代码:
SoftP p1 =new SoftP();
SoftP p2 =new SoftP();
SoftP p3 =new SoftP();
SoftP p4 =new SoftP();
p1.setCol("quantity");
p2.setCol("quantity");
p3.setCol("quantity");
p4.setCol("quantity");
p1.setInputboxValue("100");
p2.setInputboxValue("200");
p3.setInputboxValue("300");
p4.setInputboxValue("400");
List<SoftP>testListj=new ArrayList<SoftP>();
testListj.add(p1);
testListj.add(p2);
testListj.add(p3);
testListj.add(p4);
MinBuilder orderByMin=null;
for(SoftP s:testListj){
orderByMin= AggregationBuilders.min(s.getInputboxValue()).field(s.getCol());
}
Client client=null;
SearchResponse sr = client.prepareSearch()
.setQuery( QueryBuilders.matchAllQuery() )
.addAggregation( orderByMin )
.execute().actionGet();
System.out.println("sr>>>>>>>>>>>>>>>>>>>>"+sr);