MultiSearchRequestBuilder

MultiSearchRequestBuilder

我已经编写了一个查询,并希望在每个查询执行中动态设置索引。如何传递索引名称。

MultiSearchRequestBuilder multiSearchRequestBuilder = null;
 multiSearchRequestBuilder = client.prepareMultiSearch()

最佳答案

您需要针对要选择的任何索引的每个请求构建一个SearchRequest,然后将该SearchRequest添加到MultiSearchRequestBuilder

SearchRequest searchRequest1 = new SearchRequest("index1");
multiSearchRequestBuilder.add(searchRequest1);
SearchRequest searchRequest2 = new SearchRequest("index2");
multiSearchRequestBuilder.add(searchRequest2);

关于java - Elasticsearch MultiSearchRequestBuilder,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/50128323/

10-11 09:02