Use SearchRequest copy constructor in ExpandSearchPhase (#36772)
Relates to #36641
This commit is contained in:
parent
dd540ef618
commit
d2ce576c8c
|
@ -91,7 +91,8 @@ final class ExpandSearchPhase extends SearchPhase {
|
||||||
SearchSourceBuilder sourceBuilder = buildExpandSearchSourceBuilder(innerHitBuilder, innerCollapseBuilder)
|
SearchSourceBuilder sourceBuilder = buildExpandSearchSourceBuilder(innerHitBuilder, innerCollapseBuilder)
|
||||||
.query(groupQuery)
|
.query(groupQuery)
|
||||||
.postFilter(searchRequest.source().postFilter());
|
.postFilter(searchRequest.source().postFilter());
|
||||||
SearchRequest groupRequest = buildExpandSearchRequest(searchRequest, sourceBuilder);
|
SearchRequest groupRequest = new SearchRequest(searchRequest);
|
||||||
|
groupRequest.source(sourceBuilder);
|
||||||
multiRequest.add(groupRequest);
|
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) {
|
private SearchSourceBuilder buildExpandSearchSourceBuilder(InnerHitBuilder options, CollapseBuilder innerCollapseBuilder) {
|
||||||
SearchSourceBuilder groupSource = new SearchSourceBuilder();
|
SearchSourceBuilder groupSource = new SearchSourceBuilder();
|
||||||
groupSource.from(options.getFrom());
|
groupSource.from(options.getFrom());
|
||||||
|
|
Loading…
Reference in New Issue