Skip to content

Commit

Permalink
Including changes to javadoc, CHANGELOG.md and request builders
Browse files Browse the repository at this point in the history
Signed-off-by: Ankit Jain <[email protected]>
  • Loading branch information
jainankitk committed Apr 17, 2024
1 parent a12dd35 commit 3d9b1c3
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 16 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- [Concurrent Segment Search] Disable concurrent segment search for system indices and throttled requests ([#12954](https://github.com/opensearch-project/OpenSearch/pull/12954))
- Derived fields support to derive field values at query time without indexing ([#12569](https://github.com/opensearch-project/OpenSearch/pull/12569))
- Detect breaking changes on pull requests ([#9044](https://github.com/opensearch-project/OpenSearch/pull/9044))
- Adding support for ignore_unavailable_shards in search request ([#13209](https://github.com/opensearch-project/OpenSearch/pull/13209))
- Add cluster primary balance contraint for rebalancing with buffer ([#12656](https://github.com/opensearch-project/OpenSearch/pull/12656))
- [Remote Store] Make translog transfer timeout configurable ([#12704](https://github.com/opensearch-project/OpenSearch/pull/12704))
- Reject Resize index requests (i.e, split, shrink and clone), While DocRep to SegRep migration is in progress.([#12686](https://github.com/opensearch-project/OpenSearch/pull/12686))
Expand Down Expand Up @@ -140,7 +141,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- Fix bulk API ignores ingest pipeline for upsert ([#12883](https://github.com/opensearch-project/OpenSearch/pull/12883))
- Fix issue with feature flags where default value may not be honored ([#12849](https://github.com/opensearch-project/OpenSearch/pull/12849))
- Fix UOE While building Exists query for nested search_as_you_type field ([#12048](https://github.com/opensearch-project/OpenSearch/pull/12048))
- Client with Java 8 runtime and Apache HttpClient 5 Transport fails with java.lang.NoSuchMethodError: java.nio.ByteBuffer.flip()Ljava/nio/ByteBuffer ([#13100](https://github.com/opensearch-project/opensearch-java/pull/13100))
- Client with Java 8 runtime and Apache HttpClient 5 Transport fails with java.lang.NoSuchMethodError: java.nio.ByteBuffer.flip()Ljava/nio/ByteBuffer ([#13100](https://github.com/opensearch-project/opensearch-java/pull/13100))

### Security

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,9 @@ static void addSearchRequestParams(Params params, SearchRequest searchRequest) {
if (searchRequest.allowPartialSearchResults() != null) {
params.withAllowPartialResults(searchRequest.allowPartialSearchResults());
}
if (searchRequest.ignoreUnavailable() != null) {
params.withIgnoreUnavailable(searchRequest.ignoreUnavailable());
}
params.withBatchedReduceSize(searchRequest.getBatchedReduceSize());
if (searchRequest.scroll() != null) {
params.putParam("scroll", searchRequest.scroll().keepAlive());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ public final void executeNextPhase(SearchPhase currentPhase, SearchPhase nextPha
currentPhase.getName()
);
}
if (!request.getIgnoreUnavailableShards()) {
if (!request.ignoreUnavailable()) {
onPhaseFailure(currentPhase, "Partial shards failure (" + discrepancy + " shards unavailable)", null);
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public class SearchRequest extends ActionRequest implements IndicesRequest.Repla

private Boolean allowPartialSearchResults;

private Boolean ignoreUnavailableShards;
private Boolean ignoreUnavailable;

private Scroll scroll;

Expand Down Expand Up @@ -200,7 +200,7 @@ private SearchRequest(
boolean finalReduce
) {
this.allowPartialSearchResults = searchRequest.allowPartialSearchResults;
this.ignoreUnavailableShards = searchRequest.ignoreUnavailableShards;
this.ignoreUnavailable = searchRequest.ignoreUnavailable;
this.batchedReduceSize = searchRequest.batchedReduceSize;
this.ccsMinimizeRoundtrips = searchRequest.ccsMinimizeRoundtrips;
this.indices = indices;
Expand Down Expand Up @@ -250,7 +250,7 @@ public SearchRequest(StreamInput in) throws IOException {
preFilterShardSize = in.readOptionalVInt();
allowPartialSearchResults = in.readOptionalBoolean();
if (in.getVersion().onOrAfter(Version.V_2_14_0)) {
ignoreUnavailableShards = in.readOptionalBoolean();
ignoreUnavailable = in.readOptionalBoolean();
}
localClusterAlias = in.readOptionalString();
if (localClusterAlias != null) {
Expand Down Expand Up @@ -290,7 +290,7 @@ public void writeTo(StreamOutput out) throws IOException {
out.writeOptionalVInt(preFilterShardSize);
out.writeOptionalBoolean(allowPartialSearchResults);
if (out.getVersion().onOrAfter(Version.V_2_14_0)) {
out.writeOptionalBoolean(ignoreUnavailableShards);
out.writeOptionalBoolean(ignoreUnavailable);
}
out.writeOptionalString(localClusterAlias);
if (localClusterAlias != null) {
Expand Down Expand Up @@ -576,13 +576,18 @@ public Boolean allowPartialSearchResults() {
return this.allowPartialSearchResults;
}

public SearchRequest ignoreUnavailableShards(boolean ignoreUnavailableShards) {
this.ignoreUnavailableShards = ignoreUnavailableShards;
/**
* Sets if this request should ignore unavailable shards. This option is superseded
* by allowPartialSearchResults (ignores any type of shard failures) instead of just
* unavailable shards. (If method is not called, will default to the cluster level setting).
*/
public SearchRequest ignoreUnavailable(boolean ignoreUnavailable) {
this.ignoreUnavailable = ignoreUnavailable;
return this;
}

public Boolean getIgnoreUnavailableShards() {
return this.ignoreUnavailableShards;
public Boolean ignoreUnavailable() {
return this.ignoreUnavailable;
}

/**
Expand Down Expand Up @@ -765,7 +770,7 @@ public boolean equals(Object o) {
&& Objects.equals(preFilterShardSize, that.preFilterShardSize)
&& Objects.equals(indicesOptions, that.indicesOptions)
&& Objects.equals(allowPartialSearchResults, that.allowPartialSearchResults)
&& Objects.equals(ignoreUnavailableShards, that.ignoreUnavailableShards)
&& Objects.equals(ignoreUnavailable, that.ignoreUnavailable)
&& Objects.equals(localClusterAlias, that.localClusterAlias)
&& absoluteStartMillis == that.absoluteStartMillis
&& ccsMinimizeRoundtrips == that.ccsMinimizeRoundtrips
Expand All @@ -789,7 +794,7 @@ public int hashCode() {
maxConcurrentShardRequests,
preFilterShardSize,
allowPartialSearchResults,
ignoreUnavailableShards,
ignoreUnavailable,
localClusterAlias,
absoluteStartMillis,
ccsMinimizeRoundtrips,
Expand Down Expand Up @@ -825,8 +830,8 @@ public String toString() {
+ preFilterShardSize
+ ", allowPartialSearchResults="
+ allowPartialSearchResults
+ ", ignoreUnavailableShards="
+ ignoreUnavailableShards
+ ", ignoreUnavailable="
+ ignoreUnavailable
+ ", localClusterAlias="
+ localClusterAlias
+ ", getOrCreateAbsoluteStartMillis="
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -556,6 +556,15 @@ public SearchRequestBuilder setAllowPartialSearchResults(boolean allowPartialSea
return this;
}

/**
* Sets if this request should ignore unavailable shards. (If method is not called,
* will default to the cluster level setting).
*/
public SearchRequestBuilder setIgnoreUnavailable(boolean ignoreUnavailable) {
request.ignoreUnavailable(ignoreUnavailable);
return this;
}

/**
* Should the query be profiled. Defaults to <code>false</code>
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,9 +183,9 @@ public static void parseSearchRequest(
searchRequest.allowPartialSearchResults(request.paramAsBoolean("allow_partial_search_results", null));
}

if (request.hasParam("ignore_unavailable_shards")) {
if (request.hasParam("ignore_unavailable")) {
// only set if we have the parameter passed to override the cluster-level default
searchRequest.ignoreUnavailableShards(request.paramAsBoolean("ignore_unavailable_shards", null));
searchRequest.ignoreUnavailable(request.paramAsBoolean("ignore_unavailable", null));
}

if (request.hasParam("phase_took")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ private RandomSearchRequestGenerator() {}
public static SearchRequest randomSearchRequest(Supplier<SearchSourceBuilder> randomSearchSourceBuilder) {
SearchRequest searchRequest = new SearchRequest();
searchRequest.allowPartialSearchResults(true);
searchRequest.ignoreUnavailable(randomBoolean());
if (randomBoolean()) {
searchRequest.setCcsMinimizeRoundtrips(randomBoolean());
}
Expand Down

0 comments on commit 3d9b1c3

Please sign in to comment.