Skip to content

Add missing properties to BaseQueryBuilder. #2251

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ public class NativeQuery extends BaseQuery {
@Nullable private Suggester suggester;
@Nullable private FieldCollapse fieldCollapse;
private List<ScriptedField> scriptedFields = Collections.emptyList();
private List<RescorerQuery> rescorerQueries = Collections.emptyList();

public NativeQuery(NativeQueryBuilder builder) {
super(builder);
Expand All @@ -56,7 +55,6 @@ public NativeQuery(NativeQueryBuilder builder) {
this.suggester = builder.getSuggester();
this.fieldCollapse = builder.getFieldCollapse();
this.scriptedFields = builder.getScriptedFields();
this.rescorerQueries = builder.getRescorerQueries();
}

public NativeQuery(@Nullable Query query) {
Expand Down Expand Up @@ -94,9 +92,4 @@ public FieldCollapse getFieldCollapse() {
public List<ScriptedField> getScriptedFields() {
return scriptedFields;
}

@Override
public List<RescorerQuery> getRescorerQueries() {
return rescorerQueries;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ public class NativeQueryBuilder extends BaseQueryBuilder<NativeQuery, NativeQuer
@Nullable private Suggester suggester;
@Nullable private FieldCollapse fieldCollapse;
private final List<ScriptedField> scriptedFields = new ArrayList<>();
private List<RescorerQuery> rescorerQueries = new ArrayList<>();

public NativeQueryBuilder() {}

@Nullable
Expand Down Expand Up @@ -77,10 +75,6 @@ public List<ScriptedField> getScriptedFields() {
return scriptedFields;
}

public List<RescorerQuery> getRescorerQueries() {
return rescorerQueries;
}

public NativeQueryBuilder withQuery(Query query) {

Assert.notNull(query, "query must not be null");
Expand Down Expand Up @@ -135,14 +129,6 @@ public NativeQueryBuilder withScriptedField(ScriptedField scriptedField) {
return this;
}

public NativeQueryBuilder withResorerQuery(RescorerQuery resorerQuery) {

Assert.notNull(resorerQuery, "resorerQuery must not be null");

this.rescorerQueries.add(resorerQuery);
return this;
}

public NativeQuery build() {
return new NativeQuery(this);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@
*/
public class BaseQuery implements Query {

protected Pageable pageable = DEFAULT_PAGE;
@Nullable protected Sort sort;
protected Pageable pageable = DEFAULT_PAGE;
protected List<String> fields = new ArrayList<>();
@Nullable protected List<String> storedFields;
@Nullable protected SourceFilter sourceFilter;
Expand All @@ -67,29 +67,40 @@ public class BaseQuery implements Query {
@Nullable protected Duration timeout;
private boolean explain = false;
@Nullable protected List<Object> searchAfter;
@Nullable protected List<IndexBoost> indicesBoost;
protected List<RescorerQuery> rescorerQueries = new ArrayList<>();
@Nullable protected Boolean requestCache;
protected List<IdWithRouting> idsWithRouting = Collections.emptyList();
protected final List<RuntimeField> runtimeFields = new ArrayList<>();
@Nullable protected List<IndexBoost> indicesBoost;

public BaseQuery() {}

public <Q extends BaseQuery, B extends BaseQueryBuilder<Q, B>> BaseQuery(BaseQueryBuilder<Q, B> builder) {
this.sort = builder.getSort();
// do a setPageable after setting the sort, because the pageable may contain an additional sort
this.setPageable(builder.getPageable() != null ? builder.getPageable() : DEFAULT_PAGE);
this.ids = builder.getIds();
this.trackScores = builder.getTrackScores();
this.maxResults = builder.getMaxResults();
this.indicesOptions = builder.getIndicesOptions();
this.minScore = builder.getMinScore();
this.preference = builder.getPreference();
this.sourceFilter = builder.getSourceFilter();
this.fields = builder.getFields();
this.highlightQuery = builder.highlightQuery;
this.storedFields = builder.getStoredFields();
this.sourceFilter = builder.getSourceFilter();
this.minScore = builder.getMinScore();
this.ids = builder.getIds().isEmpty() ? null : builder.getIds();
this.route = builder.getRoute();
this.searchType = builder.getSearchType();
this.indicesOptions = builder.getIndicesOptions();
this.trackScores = builder.getTrackScores();
this.preference = builder.getPreference();
this.maxResults = builder.getMaxResults();
this.highlightQuery = builder.getHighlightQuery();
this.trackTotalHits = builder.getTrackTotalHits();
this.trackTotalHitsUpTo = builder.getTrackTotalHitsUpTo();
this.scrollTime = builder.getScrollTime();
this.timeout = builder.getTimeout();
this.explain = builder.getExplain();
this.searchAfter = builder.getSearchAfter();
this.indicesBoost = builder.getIndicesBoost();
this.rescorerQueries = builder.getRescorerQueries();
this.requestCache = builder.getRequestCache();
this.idsWithRouting = builder.getIdsWithRouting();
}

@Override
Expand Down
Loading