Use SearchRequest copy constructor in ExpandSearchPhase
Relates to
@@ -91,7 +91,8 @@ final class ExpandSearchPhase extends SearchPhase {
SearchSourceBuilder sourceBuilder = buildExpandSearchSourceBuilder(innerHitBuilder, innerCollapseBuilder)
.query(groupQuery)
.postFilter(searchRequest.source().postFilter());
- SearchRequest groupRequest = buildExpandSearchRequest(searchRequest, sourceBuilder);
+ SearchRequest groupRequest = new SearchRequest(searchRequest);
+ groupRequest.source(sourceBuilder);
multiRequest.add(groupRequest);
}
}
@@ -120,24 +121,6 @@ final class ExpandSearchPhase extends SearchPhase {
}
}
- private SearchRequest buildExpandSearchRequest(SearchRequest orig, SearchSourceBuilder sourceBuilder) {
- SearchRequest groupRequest = new SearchRequest(orig.indices())
- .types(orig.types())
- .source(sourceBuilder)
- .indicesOptions(orig.indicesOptions())
- .requestCache(orig.requestCache())
- .preference(orig.preference())
- .routing(orig.routing())
- .searchType(orig.searchType());
- if (orig.allowPartialSearchResults() != null){
- groupRequest.allowPartialSearchResults(orig.allowPartialSearchResults());
- }
- if (orig.isMaxConcurrentShardRequestsSet()) {
- groupRequest.setMaxConcurrentShardRequests(orig.getMaxConcurrentShardRequests());
- }
- return groupRequest;
- }
-
private SearchSourceBuilder buildExpandSearchSourceBuilder(InnerHitBuilder options, CollapseBuilder innerCollapseBuilder) {
SearchSourceBuilder groupSource = new SearchSourceBuilder();
groupSource.from(options.getFrom());
