Use SearchRequest copy constructor in ExpandSearchPhase (#36772)

Relates to #36641
This commit is contained in:
Luca Cavanna 2018-12-19 10:47:17 +01:00 committed by GitHub
parent dd540ef618
commit d2ce576c8c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 17 deletions

View File

@ -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,22 +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());
}
groupRequest.setMaxConcurrentShardRequests(orig.getMaxConcurrentShardRequests());
return groupRequest;
}
private SearchSourceBuilder buildExpandSearchSourceBuilder(InnerHitBuilder options, CollapseBuilder innerCollapseBuilder) {
SearchSourceBuilder groupSource = new SearchSourceBuilder();
groupSource.from(options.getFrom());