Search in sources :

Example 1 with RescorerBuilder

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;
}
Also used : SortBuilder(org.opensearch.search.sort.SortBuilder) ScoreSortBuilder(org.opensearch.search.sort.ScoreSortBuilder) AggregatorFactories(org.opensearch.search.aggregations.AggregatorFactories) AbstractQueryBuilder.parseInnerQueryBuilder(org.opensearch.index.query.AbstractQueryBuilder.parseInnerQueryBuilder) QueryBuilder(org.opensearch.index.query.QueryBuilder) HighlightBuilder(org.opensearch.search.fetch.subphase.highlight.HighlightBuilder) RescorerBuilder(org.opensearch.search.rescore.RescorerBuilder)

Aggregations

AbstractQueryBuilder.parseInnerQueryBuilder (org.opensearch.index.query.AbstractQueryBuilder.parseInnerQueryBuilder)1 QueryBuilder (org.opensearch.index.query.QueryBuilder)1 AggregatorFactories (org.opensearch.search.aggregations.AggregatorFactories)1 HighlightBuilder (org.opensearch.search.fetch.subphase.highlight.HighlightBuilder)1 RescorerBuilder (org.opensearch.search.rescore.RescorerBuilder)1 ScoreSortBuilder (org.opensearch.search.sort.ScoreSortBuilder)1 SortBuilder (org.opensearch.search.sort.SortBuilder)1