请教大神,关于MultiSearch传入多个查询请求后,查询出来的多个结果怎么和传参关联上

请教大神,关于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();
结果对应如下:

aaaaa.png

 
已邀请:

strglee - 公众号: 每日ELK ,每天分享ELK相关知识

赞同来自:

返回的结果顺序跟你搜索顺序是一样的

yayg2008

赞同来自:

既然你要mutiSearch,为何对结果又要区分关联?

要回复问题请先登录注册