use of org.opensearch.search.rescore.RescorerBuilder in project OpenSearch by opensearch-project.
the class SearchSourceBuilder method rewrite.
/**
* Rewrites this search source builder into its primitive form. e.g. by
* rewriting the QueryBuilder. If the builder did not change the identity
* reference must be returned otherwise the builder will be rewritten
* infinitely.
*/
@Override
public SearchSourceBuilder rewrite(QueryRewriteContext context) throws IOException {
assert (this.equals(shallowCopy(queryBuilder, postQueryBuilder, aggregations, sliceBuilder, sorts, rescoreBuilders, highlightBuilder)));
QueryBuilder queryBuilder = null;
if (this.queryBuilder != null) {
queryBuilder = this.queryBuilder.rewrite(context);
}
QueryBuilder postQueryBuilder = null;
if (this.postQueryBuilder != null) {
postQueryBuilder = this.postQueryBuilder.rewrite(context);
}
AggregatorFactories.Builder aggregations = null;
if (this.aggregations != null) {
aggregations = this.aggregations.rewrite(context);
}
List<SortBuilder<?>> sorts = Rewriteable.rewrite(this.sorts, context);
List<RescorerBuilder> rescoreBuilders = Rewriteable.rewrite(this.rescoreBuilders, context);
HighlightBuilder highlightBuilder = this.highlightBuilder;
if (highlightBuilder != null) {
highlightBuilder = this.highlightBuilder.rewrite(context);
}
boolean rewritten = queryBuilder != this.queryBuilder || postQueryBuilder != this.postQueryBuilder || aggregations != this.aggregations || rescoreBuilders != this.rescoreBuilders || sorts != this.sorts || this.highlightBuilder != highlightBuilder;
if (rewritten) {
return shallowCopy(queryBuilder, postQueryBuilder, aggregations, this.sliceBuilder, sorts, rescoreBuilders, highlightBuilder);
}
return this;
}
Aggregations