From cf4f928b0daa51152ab0b241bfd2ad521f09c364 Mon Sep 17 00:00:00 2001 From: Urs Keller Date: Wed, 10 Jan 2024 14:18:25 +0100 Subject: [PATCH] Add wrapper to builder Signed-off-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 59e1cc6e49..299843a722 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;