请教大神,关于MultiSearch传入多个查询请求后,查询出来的多个结果怎么和传参关联上
// 初始化两个查询
SearchRequestBuilder srb1 =client
.prepareSearch().setQuery(QueryBuilders.boolQuery()
.must(QueryBuilders.boolQuery().should(QueryBuilders.termQuery("idNumb","2028"))))
.setExplain(true);
SearchRequestBuilder srb2 = client
.prepareSearch().setQuery(QueryBuilders.boolQuery()
.must(QueryBuilders.boolQuery().should(QueryBuilders.termQuery("idNumb","2035"))))
.setExplain(true);
//将query对象放入集合中模仿传参
List<SearchRequestBuilder> arrList = new ArrayList<>();
arrList.add(srb1);
arrList.add(srb2);
//MultiSearch查询
MultiSearchRequestBuilder sr = null;
for (SearchRequestBuilder ss : arrList){
sr = client.prepareMultiSearch().add(ss);
}
MultiSearchResponse ss = sr.execute().actionGet();
结果对应如下:
3 个回复
strglee
赞同来自: zcc_vv
yayg2008
赞同来自:
zec
赞同来自: