From 2f0bf31db994320ae5fbd1b07da371aa86e9bfd0 Mon Sep 17 00:00:00 2001 From: Nathalie Jonathan <143617992+nathaliellenaa@users.noreply.github.com> Date: Mon, 2 Mar 2026 16:25:10 -0800 Subject: [PATCH] Add msearch `allow_partial_results` flag (#1904) * Add msearch allow_partial_results flag Signed-off-by: Nathalie Jonathan * Update changelog Signed-off-by: Nathalie Jonathan * Fix compilation failure Signed-off-by: Nathalie Jonathan --------- Signed-off-by: Nathalie Jonathan --- CHANGELOG.md | 1 + .../opensearch/core/MsearchRequest.java | 31 +++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 384a7a6684..c21c13f286 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) - Bump `com.github.jk1.dependency-license-report` from 3.0.1 to 3.1.1 ([#1895](https://github.com/opensearch-project/opensearch-java/pull/1895), [#1896](https://github.com/opensearch-project/opensearch-java/pull/1896)) ### Added +- Add msearch `allow_partial_results` flag ([#1904](https://github.com/opensearch-project/opensearch-java/pull/1904)) ### Fixed - Fix formatting of the main method to run for various samples ([#1749](https://github.com/opensearch-project/opensearch-java/pull/1749)) diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/core/MsearchRequest.java b/java-client/src/main/java/org/opensearch/client/opensearch/core/MsearchRequest.java index a417915504..161f22b510 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/core/MsearchRequest.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/core/MsearchRequest.java @@ -73,6 +73,9 @@ public class MsearchRequest extends RequestBase implements NdJsonpSerializable, @Nullable private final Boolean ccsMinimizeRoundtrips; + @Nullable + private final Boolean allowPartialResults; + private final List expandWildcards; @Nullable @@ -104,6 +107,7 @@ private MsearchRequest(Builder builder) { this.allowNoIndices = builder.allowNoIndices; this.cancelAfterTimeInterval = builder.cancelAfterTimeInterval; this.ccsMinimizeRoundtrips = builder.ccsMinimizeRoundtrips; + this.allowPartialResults = builder.allowPartialResults; this.expandWildcards = ApiTypeHelper.unmodifiable(builder.expandWildcards); this.ignoreThrottled = builder.ignoreThrottled; this.ignoreUnavailable = builder.ignoreUnavailable; @@ -161,6 +165,16 @@ public final Boolean ccsMinimizeRoundtrips() { return this.ccsMinimizeRoundtrips; } + /** + * If true, return partial results if there are shard request timeouts or shard failures. + *

+ * API name: {@code allow_partial_results} + */ + @Nullable + public final Boolean allowPartialResults() { + return this.allowPartialResults; + } + /** * Type of index that wildcard expressions can match. If the request can target * data streams, this argument determines whether wildcard expressions match @@ -274,6 +288,7 @@ public Builder toBuilder() { return new Builder().allowNoIndices(allowNoIndices) .cancelAfterTimeInterval(cancelAfterTimeInterval) .ccsMinimizeRoundtrips(ccsMinimizeRoundtrips) + .allowPartialResults(allowPartialResults) .expandWildcards(expandWildcards) .ignoreThrottled(ignoreThrottled) .ignoreUnavailable(ignoreUnavailable) @@ -301,6 +316,9 @@ public static class Builder extends ObjectBuilderBase implements ObjectBuilder expandWildcards; @@ -373,6 +391,16 @@ public final Builder ccsMinimizeRoundtrips(@Nullable Boolean value) { return this; } + /** + * If true, return partial results if there are shard request timeouts or shard failures. + *

+ * API name: {@code allow_partial_results} + */ + public final Builder allowPartialResults(@Nullable Boolean value) { + this.allowPartialResults = value; + return this; + } + /** * Type of index that wildcard expressions can match. If the request can target * data streams, this argument determines whether wildcard expressions match @@ -611,6 +639,9 @@ public MsearchRequest build() { if (request.ccsMinimizeRoundtrips != null) { params.put("ccs_minimize_roundtrips", String.valueOf(request.ccsMinimizeRoundtrips)); } + if (request.allowPartialResults != null) { + params.put("allow_partial_results", String.valueOf(request.allowPartialResults)); + } return params; },