From de41971c24266f3cfacdf3609947c17fc2f20acb Mon Sep 17 00:00:00 2001 From: David Zane Date: Thu, 20 Jun 2024 09:31:55 -0700 Subject: [PATCH] Add support for phase_took & search_pipeline request params Signed-off-by: David Zane --- CHANGELOG.md | 1 + .../client/opensearch/core/SearchRequest.java | 64 +++++++++++++++++++ .../core/SearchTemplateRequest.java | 64 +++++++++++++++++++ 3 files changed, 129 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4367749cd4..8ee48f45da 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ This section is for maintaining a changelog for all breaking changes for the cli ### Added - Document HTTP/2 support ([#330](https://github.com/opensearch-project/opensearch-java/pull/330)) +- Add support for phase_took & search_pipeline request params ([#1036](https://github.com/opensearch-project/opensearch-java/pull/1036)) ### Dependencies diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/core/SearchRequest.java b/java-client/src/main/java/org/opensearch/client/opensearch/core/SearchRequest.java index 9ab808705a..1d1016af1b 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/core/SearchRequest.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/core/SearchRequest.java @@ -105,6 +105,12 @@ public class SearchRequest extends RequestBase implements JsonpSerializable { @Nullable private final Boolean ccsMinimizeRoundtrips; + @Nullable + private final Boolean phaseTook; + + @Nullable + private final String pipeline; + @Nullable private final FieldCollapse collapse; @@ -239,6 +245,8 @@ private SearchRequest(Builder builder) { this.analyzer = builder.analyzer; this.batchedReduceSize = builder.batchedReduceSize; this.ccsMinimizeRoundtrips = builder.ccsMinimizeRoundtrips; + this.phaseTook = builder.phaseTook; + this.pipeline = builder.pipeline; this.collapse = builder.collapse; this.defaultOperator = builder.defaultOperator; this.df = builder.df; @@ -377,6 +385,27 @@ public final Boolean ccsMinimizeRoundtrips() { return this.ccsMinimizeRoundtrips; } + /** + * Indicates whether search phase took times should be returned + * in SearchResponse + *

+ * API name: {@code phase_took} + */ + @Nullable + public final Boolean phaseTook() { + return this.phaseTook; + } + + /** + * Specifies search pipeline name + *

+ * API name: {@code pipeline} + */ + @Nullable + public final String pipeline() { + return this.pipeline; + } + /** * API name: {@code collapse} */ @@ -1084,6 +1113,8 @@ public Builder toBuilder() { .analyzer(analyzer) .batchedReduceSize(batchedReduceSize) .ccsMinimizeRoundtrips(ccsMinimizeRoundtrips) + .phaseTook(phaseTook) + .pipeline(pipeline) .collapse(collapse) .defaultOperator(defaultOperator) .df(df) @@ -1162,6 +1193,12 @@ public static class Builder extends ObjectBuilderBase implements ObjectBuilder + * API name: {@code phase_took} + */ + public final Builder phaseTook(@Nullable Boolean value) { + this.phaseTook = value; + return this; + } + + /** + * Specifies search pipeline name + *

+ * API name: {@code pipeline} + */ + public final Builder pipeline(@Nullable String value) { + this.pipeline = value; + return this; + } + /** * API name: {@code collapse} */ @@ -2354,6 +2412,12 @@ protected static void setupSearchRequestDeserializer(ObjectDeserializer expandWildcards; @Nullable @@ -113,6 +119,8 @@ private SearchTemplateRequest(Builder builder) { this.allowNoIndices = builder.allowNoIndices; this.ccsMinimizeRoundtrips = builder.ccsMinimizeRoundtrips; + this.phaseTook = builder.phaseTook; + this.pipeline = builder.pipeline; this.expandWildcards = ApiTypeHelper.unmodifiable(builder.expandWildcards); this.explain = builder.explain; this.id = builder.id; @@ -156,6 +164,27 @@ public final Boolean ccsMinimizeRoundtrips() { return this.ccsMinimizeRoundtrips; } + /** + * Indicates whether search phase took times should be returned + * in SearchResponse + *

+ * API name: {@code phase_took} + */ + @Nullable + public final Boolean phaseTook() { + return this.phaseTook; + } + + /** + * Specifies search pipeline name + *

+ * API name: {@code pipeline} + */ + @Nullable + public final String pipeline() { + return this.pipeline; + } + /** * Whether to expand wildcard expression to concrete indices that are open, * closed or both. @@ -334,6 +363,8 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { public Builder toBuilder() { return new Builder().allowNoIndices(allowNoIndices) .ccsMinimizeRoundtrips(ccsMinimizeRoundtrips) + .phaseTook(phaseTook) + .pipeline(pipeline) .expandWildcards(expandWildcards) .explain(explain) .id(id) @@ -362,6 +393,12 @@ public static class Builder extends ObjectBuilderBase implements ObjectBuilder expandWildcards; @@ -424,6 +461,27 @@ public final Builder ccsMinimizeRoundtrips(@Nullable Boolean value) { return this; } + /** + * Indicates whether search phase took times should be returned + * in SearchResponse + *

+ * API name: {@code phase_took} + */ + public final Builder phaseTook(@Nullable Boolean value) { + this.phaseTook = value; + return this; + } + + /** + * Specifies search pipeline name + *

+ * API name: {@code pipeline} + */ + public final Builder pipeline(@Nullable String value) { + this.pipeline = value; + return this; + } + /** * Whether to expand wildcard expression to concrete indices that are open, * closed or both. @@ -700,6 +758,12 @@ protected static void setupSearchTemplateRequestDeserializer(ObjectDeserializer< if (request.ccsMinimizeRoundtrips != null) { params.put("ccs_minimize_roundtrips", String.valueOf(request.ccsMinimizeRoundtrips)); } + if (request.phaseTook != null) { + params.put("phase_took", String.valueOf(request.phaseTook)); + } + if (request.pipeline != null) { + params.put("search_pipeline", request.pipeline); + } if (request.routing != null) { params.put("routing", request.routing); }