diff --git a/core/src/main/java/org/elasticsearch/action/search/SearchRequest.java b/core/src/main/java/org/elasticsearch/action/search/SearchRequest.java index 8c1d8b3766830..cc200081be7ce 100644 --- a/core/src/main/java/org/elasticsearch/action/search/SearchRequest.java +++ b/core/src/main/java/org/elasticsearch/action/search/SearchRequest.java @@ -79,6 +79,8 @@ public final class SearchRequest extends ActionRequest implements IndicesRequest private IndicesOptions indicesOptions = DEFAULT_INDICES_OPTIONS; + private Boolean isThrottled; + public SearchRequest() { } @@ -303,6 +305,17 @@ public boolean isSuggestOnly() { return source != null && source.isSuggestOnly(); } + /** + * Sets if this request will be executed on SEARCH_THROTTLED thread pool, rather than the SEARCH thread pool. + */ + public void isThrottled(Boolean isThrottled) { + this.isThrottled = isThrottled; + } + + public Boolean isThrottled() { + return isThrottled; + } + @Override public Task createTask(long id, String type, String action, TaskId parentTaskId) { // generating description in a lazy way since source can be quite big @@ -342,6 +355,7 @@ public void readFrom(StreamInput in) throws IOException { types = in.readStringArray(); indicesOptions = IndicesOptions.readIndicesOptions(in); requestCache = in.readOptionalBoolean(); + isThrottled = in.readOptionalBoolean(); if (in.getVersion().onOrAfter(Version.V_5_4_0_UNRELEASED)) { batchedReduceSize = in.readVInt(); } @@ -362,6 +376,7 @@ public void writeTo(StreamOutput out) throws IOException { out.writeStringArray(types); indicesOptions.writeIndicesOptions(out); out.writeOptionalBoolean(requestCache); + out.writeOptionalBoolean(isThrottled); if (out.getVersion().onOrAfter(Version.V_5_4_0_UNRELEASED)) { out.writeVInt(batchedReduceSize); } @@ -382,6 +397,7 @@ public boolean equals(Object o) { Objects.equals(preference, that.preference) && Objects.equals(source, that.source) && Objects.equals(requestCache, that.requestCache) && + Objects.equals(isThrottled, that.isThrottled) && Objects.equals(scroll, that.scroll) && Arrays.equals(types, that.types) && Objects.equals(indicesOptions, that.indicesOptions); @@ -390,7 +406,7 @@ public boolean equals(Object o) { @Override public int hashCode() { return Objects.hash(searchType, Arrays.hashCode(indices), routing, preference, source, requestCache, - scroll, Arrays.hashCode(types), indicesOptions); + isThrottled, scroll, Arrays.hashCode(types), indicesOptions); } @Override @@ -403,6 +419,7 @@ public String toString() { ", routing='" + routing + '\'' + ", preference='" + preference + '\'' + ", requestCache=" + requestCache + + ", isThrottled=" + isThrottled + ", scroll=" + scroll + ", source=" + source + '}'; }