From b50fdb84d801a1260ccc3e818e2c69b6f890c4e1 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 --- CHANGELOG.md | 6 +++--- .../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, 15 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 86adbe733f..f3c48bd755 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -36,13 +36,13 @@ This section is for maintaining a changelog for all breaking changes for the cli ### Added - Added support for icu_collation_keyword type ([#725](https://github.com/opensearch-project/opensearch-java/pull/725)) - Added support for flat_object field property ([#735](https://github.com/opensearch-project/opensearch-java/pull/735)) - +- Added toQuery method in Query and QueryVariant ([#760](https://github.com/opensearch-project/opensearch-java/pull/760) ### Dependencies ### Changed ### Deprecated - +- Deprecated "_toQuery()" in Query and QueryVariant ([#760](https://github.com/opensearch-project/opensearch-java/pull/760) ### Removed ### Fixed @@ -251,4 +251,4 @@ This section is for maintaining a changelog for all breaking changes for the cli [2.5.0]: https://github.com/opensearch-project/opensearch-java/compare/v2.4.0...v2.5.0 [2.4.0]: https://github.com/opensearch-project/opensearch-java/compare/v2.3.0...v2.4.0 [2.3.0]: https://github.com/opensearch-project/opensearch-java/compare/v2.2.0...v2.3.0 -[2.2.0]: https://github.com/opensearch-project/opensearch-java/compare/v2.1.0...v2.2.0 \ No newline at end of file +[2.2.0]: https://github.com/opensearch-project/opensearch-java/compare/v2.1.0...v2.2.0 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() ) ) );