Skip to content
Open
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 @@ -1426,6 +1426,7 @@ private <T> void prepareSearchRequest(Query query, @Nullable String routing, @Nu
.searchType(searchType) //
.timeout(timeStringMs(query.getTimeout())) //
.requestCache(query.getRequestCache()) //
.includeNamedQueriesScore(query.getIncludeNamedQueriesScore()) //
;

var pointInTime = query.getPointInTime();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ public class BaseQuery implements Query {
protected List<IdWithRouting> idsWithRouting = Collections.emptyList();
protected List<RuntimeField> runtimeFields = new ArrayList<>();
@Nullable protected PointInTime pointInTime;
@Nullable protected Boolean includeNamedQueriesScore;
private boolean queryIsUpdatedByConverter = false;
@Nullable private Integer reactiveBatchSize = null;
@Nullable private Boolean allowNoIndices = null;
Expand Down Expand Up @@ -123,6 +124,7 @@ public <Q extends BaseQuery, B extends BaseQueryBuilder<Q, B>> BaseQuery(BaseQue
this.docValueFields = builder.getDocValueFields();
this.scriptedFields = builder.getScriptedFields();
this.runtimeFields = builder.getRuntimeFields();
this.includeNamedQueriesScore = builder.getIncludeNamedQueriesScore();
}

/**
Expand Down Expand Up @@ -455,6 +457,11 @@ public void setRequestCache(@Nullable Boolean value) {
this.requestCache = value;
}

@Override
public void setIncludeNamedQueriesScore(@Nullable Boolean value) {
this.includeNamedQueriesScore = value;
}

@Override
@Nullable
public Boolean getRequestCache() {
Expand All @@ -480,6 +487,11 @@ public List<IndexBoost> getIndicesBoost() {
return indicesBoost;
}

@Override
public @Nullable Boolean getIncludeNamedQueriesScore() {
return this.includeNamedQueriesScore;
}

/**
* @since 5.0
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ public abstract class BaseQueryBuilder<Q extends BaseQuery, SELF extends BaseQue
@Nullable Integer reactiveBatchSize;
private final List<DocValueField> docValueFields = new ArrayList<>();
private final List<ScriptedField> scriptedFields = new ArrayList<>();
@Nullable private Boolean includeNamedQueryScore;

@Nullable
public Sort getSort() {
Expand Down Expand Up @@ -177,6 +178,11 @@ public Boolean getRequestCache() {
return requestCache;
}

@Nullable
public Boolean getIncludeNamedQueriesScore(){
return includeNamedQueryScore;
}

public List<Query.IdWithRouting> getIdsWithRouting() {
return idsWithRouting;
}
Expand Down Expand Up @@ -381,6 +387,11 @@ public SELF withRequestCache(@Nullable Boolean requestCache) {
return self();
}

public SELF withIncludeNamedQueryScore (@Nullable Boolean namedQueryScore) {
this.includeNamedQueryScore = namedQueryScore;
return self();
}

/**
* Set Ids with routing values for a multi-get request run with this query. Not used in any other searches.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,20 @@ default Integer getReactiveBatchSize() {
*/
public Integer getRequestSize();

/**
* Sets the include_named_queries_score value for the query.
* If true, the response includes the score contribution from any named queries.
*
* @param value new value
*/
void setIncludeNamedQueriesScore(@Nullable Boolean value);

/**
* @return the include_named_queries_score value for this query.
*/
@Nullable
Boolean getIncludeNamedQueriesScore();

/**
* @since 4.3
*/
Expand Down