From c3cb5e27792ded9bbdf1835d787c547c10ee4b39 Mon Sep 17 00:00:00 2001 From: Dante Date: Sat, 9 Dec 2023 06:56:21 +0900 Subject: [PATCH] rename _toQuery() to toQuery() (#760) * rename _toQuery() to toQuery() Signed-off-by: channel-dante * update CHANGELOG.md Signed-off-by: channel-dante * update CHANGELOG.md Signed-off-by: channel-dante --------- Signed-off-by: channel-dante (cherry picked from commit b50fdb84d801a1260ccc3e818e2c69b6f890c4e1) Signed-off-by: channel-dante --- CHANGELOG.md | 2 ++ .../client/opensearch/_types/query_dsl/QueryVariant.java | 4 ++++ .../client/opensearch/experiments/api/query2/Query.java | 5 +++++ .../client/opensearch/experiments/api/query2/QueryTest.java | 2 +- .../client/opensearch/integTest/AbstractRequestIT.java | 4 ++-- 5 files changed, 14 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a48ae8b2bf..3e60f53d6e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) - Added support for flat_object field property ([#735](https://github.com/opensearch-project/opensearch-java/pull/735)) - Expose HTTP status code through `ResponseException#status` ([#756](https://github.com/opensearch-project/opensearch-java/pull/756)) - Added toBuilder method to all request model in core package & _types.query_dsl package ([#766](https://github.com/opensearch-project/opensearch-java/pull/766)) +- Added toQuery method in Query and QueryVariant ([#760](https://github.com/opensearch-project/opensearch-java/pull/760) ### Dependencies - Bumps `com.diffplug.spotless` from 6.22.0 to 6.23.3 @@ -15,6 +16,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) ### Changed ### Deprecated +- Deprecated "_toQuery()" in Query and QueryVariant ([#760](https://github.com/opensearch-project/opensearch-java/pull/760) ### Removed diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/QueryVariant.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/QueryVariant.java index 16db07a1ab..8ec793bd21 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/QueryVariant.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/QueryVariant.java @@ -39,8 +39,12 @@ public interface QueryVariant { Query.Kind _queryKind(); + @Deprecated default Query _toQuery() { return new Query(this); } + default Query toQuery() { + return new Query(this); + } } diff --git a/java-client/src/test/java/org/opensearch/client/opensearch/experiments/api/query2/Query.java b/java-client/src/test/java/org/opensearch/client/opensearch/experiments/api/query2/Query.java index 617d6668a0..74d2b2ab25 100644 --- a/java-client/src/test/java/org/opensearch/client/opensearch/experiments/api/query2/Query.java +++ b/java-client/src/test/java/org/opensearch/client/opensearch/experiments/api/query2/Query.java @@ -50,9 +50,14 @@ public class Query implements TaggedUnion, JsonpSerializable { public interface Variant extends UnionVariant, JsonpSerializable { + @Deprecated default Query _toQuery() { return new Query(this); } + + default Query toQuery() { + return new Query(this); + } } public enum Kind implements JsonEnum { diff --git a/java-client/src/test/java/org/opensearch/client/opensearch/experiments/api/query2/QueryTest.java b/java-client/src/test/java/org/opensearch/client/opensearch/experiments/api/query2/QueryTest.java index 6405ad3d44..5cd3d1d564 100644 --- a/java-client/src/test/java/org/opensearch/client/opensearch/experiments/api/query2/QueryTest.java +++ b/java-client/src/test/java/org/opensearch/client/opensearch/experiments/api/query2/QueryTest.java @@ -48,7 +48,7 @@ public void testQuery() { Query.Variant v = q._get(); assertEquals(Query.Kind.Bool, v._variantType()); - Query q1 = v._toQuery(); + Query q1 = v.toQuery(); Collection must = q.bool().must(); diff --git a/java-client/src/test/java/org/opensearch/client/opensearch/integTest/AbstractRequestIT.java b/java-client/src/test/java/org/opensearch/client/opensearch/integTest/AbstractRequestIT.java index 716cc4b25d..5179443cc4 100644 --- a/java-client/src/test/java/org/opensearch/client/opensearch/integTest/AbstractRequestIT.java +++ b/java-client/src/test/java/org/opensearch/client/opensearch/integTest/AbstractRequestIT.java @@ -495,9 +495,9 @@ public void testSubAggregation() throws IOException { .filter( BoolQuery.of( _5 -> _5.filter( - List.of(TermsQuery.of(_6 -> _6.field("color.keyword").terms(_7 -> _7.value(fieldValues)))._toQuery()) + List.of(TermsQuery.of(_6 -> _6.field("color.keyword").terms(_7 -> _7.value(fieldValues))).toQuery()) ) - )._toQuery() + ).toQuery() ) ) );