From 550dd4b1e523d4d5d0d1c03104ace317dda4ccb9 Mon Sep 17 00:00:00 2001 From: Urs Keller Date: Thu, 18 Jan 2024 19:52:45 +0100 Subject: [PATCH] Add wrapper to builder (#806) Signed-off-by: Urs Keller Co-authored-by: Urs Keller --- CHANGELOG.md | 2 ++ .../opensearch/_types/query_dsl/Query.java | 27 +++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 38cae4401b..05399e20bd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,8 @@ 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)) - Expose HTTP status code through `ResponseException#status` ([#756](https://github.com/opensearch-project/opensearch-java/pull/756)) +- Added missing WrapperQuery accessors and builder methods ([#806](https://github.com/opensearch-project/opensearch-java/pull/806)) + ### Dependencies diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/Query.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/Query.java index 0890341a86..6167d02d3d 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/Query.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/Query.java @@ -1153,6 +1153,23 @@ public WildcardQuery wildcard() { return TaggedUnionUtils.get(this, Kind.Wildcard); } + /** + * Is this variant instance of kind {@code wrapper}? + */ + public boolean isWrapper() { + return this._kind == Query.Kind.Wrapper; + } + + /** + * Get the {@code wrapper} variant value. + * + * @throws IllegalStateException + * if the current variant is not of the {@code wrapper} kind. + */ + public WrapperQuery wrapper() { + return (WrapperQuery) TaggedUnionUtils.get(this, Query.Kind.Wrapper); + } + /** * Is this variant instance of kind {@code type}? */ @@ -1743,6 +1760,16 @@ public ObjectBuilder wildcard(Function wrapper(WrapperQuery v) { + this._kind = Query.Kind.Wrapper; + this._value = v; + return this; + } + + public ObjectBuilder wrapper(Function> fn) { + return this.wrapper(fn.apply(new WrapperQuery.Builder()).build()); + } + public ObjectBuilder type(TypeQuery v) { this._kind = Kind.Type; this._value = v;