From 47c7248c9c8ed8119261aedb0437702543e3acf4 Mon Sep 17 00:00:00 2001 From: Abhinav Nath Date: Fri, 7 Oct 2022 14:42:45 +0530 Subject: [PATCH 01/16] Add support to parse sub-aggregations from filter/nested aggregations Signed-off-by: Abhinav Nath --- .../SingleBucketAggregateBase.java | 37 +++++++++++-- .../opensearch/integTest/RequestTest.java | 52 ++++++++++++++++++- 2 files changed, 85 insertions(+), 4 deletions(-) diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/aggregations/SingleBucketAggregateBase.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/aggregations/SingleBucketAggregateBase.java index 8d8582b12..a1853030d 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/aggregations/SingleBucketAggregateBase.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/aggregations/SingleBucketAggregateBase.java @@ -41,23 +41,35 @@ import org.opensearch.client.json.ObjectDeserializer; import org.opensearch.client.util.ApiTypeHelper; import jakarta.json.stream.JsonGenerator; +import org.opensearch.client.util.ObjectBuilder; + +import javax.annotation.Nullable; +import java.util.HashMap; +import java.util.Map; +import java.util.function.Function; // typedef: _types.aggregations.SingleBucketAggregateBase public abstract class SingleBucketAggregateBase extends AggregateBase { + private final Map aggregations; private final long docCount; // --------------------------------------------------------------------------------------------- protected SingleBucketAggregateBase(AbstractBuilder builder) { super(builder); + this.aggregations = ApiTypeHelper.unmodifiable(builder.aggregations); this.docCount = ApiTypeHelper.requireNonNull(builder.docCount, this, "docCount"); } + public final Map aggregations() { + return this.aggregations; + } + /** * Required - API name: {@code doc_count} */ @@ -76,11 +88,24 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { protected abstract static class AbstractBuilder> extends AggregateBase.AbstractBuilder { + @Nullable + protected Map aggregations = new HashMap<>(); private Long docCount; - /** - * Required - API name: {@code doc_count} - */ + public final BuilderT aggregations(Map aggregateMap) { + this.aggregations = _mapPutAll(this.aggregations, aggregateMap); + return self(); + } + + public final BuilderT aggregations(String key, Aggregate value) { + this.aggregations = _mapPut(this.aggregations, key, value); + return self(); + } + + public final BuilderT aggregations(String key, Function> function) { + return aggregations(key, function.apply(new Aggregate.Builder()).build()); + } + public final BuilderT docCount(long value) { this.docCount = value; return self(); @@ -94,6 +119,12 @@ protected static > void setupSingleBu AggregateBase.setupAggregateBaseDeserializer(op); op.add(AbstractBuilder::docCount, JsonpDeserializer.longDeserializer(), "doc_count"); + op.setUnknownFieldHandler((builder, name, parser, mapper) -> { + if (builder.aggregations == null) { + builder.aggregations = new HashMap<>(); + } + Aggregate._TYPED_KEYS_DESERIALIZER.deserializeEntry(name, parser, mapper, builder.aggregations); + }); } } diff --git a/java-client/src/test/java/org/opensearch/client/opensearch/integTest/RequestTest.java b/java-client/src/test/java/org/opensearch/client/opensearch/integTest/RequestTest.java index 1f8046378..4d6ae2d73 100644 --- a/java-client/src/test/java/org/opensearch/client/opensearch/integTest/RequestTest.java +++ b/java-client/src/test/java/org/opensearch/client/opensearch/integTest/RequestTest.java @@ -36,10 +36,15 @@ import org.junit.Test; import org.opensearch.Version; import org.opensearch.client.opensearch.OpenSearchAsyncClient; +import org.opensearch.client.opensearch._types.FieldValue; import org.opensearch.client.opensearch._types.OpenSearchException; import org.opensearch.client.opensearch._types.Refresh; +import org.opensearch.client.opensearch._types.aggregations.Aggregate; import org.opensearch.client.opensearch._types.aggregations.HistogramAggregate; +import org.opensearch.client.opensearch._types.aggregations.TermsAggregation; import org.opensearch.client.opensearch._types.mapping.Property; +import org.opensearch.client.opensearch._types.query_dsl.BoolQuery; +import org.opensearch.client.opensearch._types.query_dsl.TermsQuery; import org.opensearch.client.opensearch.cat.NodesResponse; import org.opensearch.client.opensearch.core.BulkResponse; import org.opensearch.client.opensearch.core.ClearScrollResponse; @@ -48,6 +53,7 @@ import org.opensearch.client.opensearch.core.InfoResponse; import org.opensearch.client.opensearch.core.MsearchResponse; import org.opensearch.client.opensearch.core.SearchResponse; +import org.opensearch.client.opensearch.core.SearchRequest; import org.opensearch.client.opensearch.core.bulk.OperationType; import org.opensearch.client.opensearch.core.msearch.RequestItem; import org.opensearch.client.opensearch.indices.CreateIndexResponse; @@ -58,9 +64,9 @@ import org.opensearch.client.opensearch.model.ModelTestCase; import org.opensearch.client.transport.endpoints.BooleanResponse; - import java.io.IOException; import java.util.Collections; +import java.util.List; import java.util.Map; import java.util.concurrent.CompletableFuture; import java.util.concurrent.ExecutionException; @@ -330,6 +336,44 @@ public void testSearchAggregation() throws IOException { } + @Test + public void testSubAggregation() throws IOException { + + highLevelClient().create(_1 -> _1.index("products").id("A").document(new Product(5, "Blue")).refresh(Refresh.True)); + highLevelClient().create(_1 -> _1.index("products").id("B").document(new Product(10, "Blue")).refresh(Refresh.True)); + highLevelClient().create(_1 -> _1.index("products").id("C").document(new Product(15, "Black")).refresh(Refresh.True)); + + List fieldValues = List.of(FieldValue.of("Blue")); + + SearchRequest searchRequest = SearchRequest.of(_1 -> _1 + .index("products") + .size(0) + .aggregations( + "price", _3 -> _3 + .aggregations(Map.of("price", TermsAggregation.of(_4 -> _4 + .field("price")) + ._toAggregation())) + .filter(BoolQuery.of(_5 -> _5 + .filter(List.of(TermsQuery.of(_6 -> _6 + .field("color.keyword") + .terms(_7 -> _7 + .value(fieldValues))) + ._toQuery()))) + ._toQuery() + ) + )); + SearchResponse searchResponse = highLevelClient().search(searchRequest, Product.class); + + Aggregate prices = searchResponse.aggregations().get("price")._get()._toAggregate(); + assertEquals(2, searchResponse.aggregations().get("price").filter().docCount()); + assertEquals(1, prices.filter().aggregations().get("price").dterms().buckets().array().get(0).docCount()); + assertEquals(1, prices.filter().aggregations().get("price").dterms().buckets().array().get(1).docCount()); + + // We've set "size" to zero + assertEquals(0, searchResponse.hits().hits().size()); + + } + @Test public void testGetMapping() throws Exception { // See also VariantsTest.testNestedTaggedUnionWithDefaultTag() @@ -405,12 +449,18 @@ public void setMsg(String msg) { public static class Product { public double price; + public String color; public Product() {} public Product(double price) { this.price = price; } + public Product(double price, String color) { + this.price = price; + this.color = color; + } + public double getPrice() { return this.price; } From e7107c9a846245f5a1c68278c0c572ae157e5f82 Mon Sep 17 00:00:00 2001 From: Abhinav Nath Date: Thu, 20 Oct 2022 17:20:22 +0530 Subject: [PATCH 02/16] Add USER_GUIDE.md Signed-off-by: Abhinav Nath --- USER_GUIDE.md | 122 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 122 insertions(+) create mode 100644 USER_GUIDE.md diff --git a/USER_GUIDE.md b/USER_GUIDE.md new file mode 100644 index 000000000..f51063052 --- /dev/null +++ b/USER_GUIDE.md @@ -0,0 +1,122 @@ +# User Guide + +- [User Guide](#user-guide) + - [Sample data](#sample-data) + - [Create an index](#create-an-index) + - [Index data](#index-data) + - [Search for the document](#search-for-the-document) + - [Search documents using a match query](#search-documents-using-a-match-query) + - [Aggregations](#aggregations) + - [Delete the document](#delete-the-document) + - [Delete the index](#delete-the-index) + - [Aggregations](#aggregations) + +## Sample data + +### IndexData class + +```java +static class IndexData { + private String firstName; + private String lastName; + + public IndexData(String firstName, String lastName) { + this.firstName = firstName; + this.lastName = lastName; + } + + public String getFirstName() { + return firstName; + } + + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + public String getLastName() { + return lastName; + } + + public void setLastName(String lastName) { + this.lastName = lastName; + } + + @Override + public String toString() { + return String.format("IndexData{first name='%s', last name='%s'}", firstName, lastName); + } +} +``` + +## Create an index + +```java +String index = "sample-index"; +CreateIndexRequest createIndexRequest = new CreateIndexRequest.Builder().index(index).build(); +client.indices().create(createIndexRequest); +``` + +## Index data + +```java +IndexData indexData = new IndexData("John", "Doe"); +IndexRequest indexRequest = new IndexRequest.Builder().index(index).id("1").document(indexData).build(); +client.index(indexRequest); + +indexData = new IndexData("John", "Joe"); +indexRequest = new IndexRequest.Builder().index(index).id("2").document(indexData).build(); +client.index(indexRequest); +``` + +## Search for the documents + +```java +SearchResponse searchResponse = client.search(s -> s.index(index), IndexData.class); +for (int i = 0; i < searchResponse.hits().hits().size(); i++) { + System.out.println(searchResponse.hits().hits().get(i).source()); +} +``` + +## Search documents using a match query + +```java +SearchRequest searchRequest = new SearchRequest.Builder().query(q -> q.match(m -> m.field("firstName") + .query(FieldValue.of("John")))) + .build(); + +SearchResponse searchResponse = client.search(searchRequest, IndexData.class); +for (int i = 0; i < searchResponse.hits().hits().size(); i++) { + System.out.println(searchResponse.hits().hits().get(i).source()); +} +``` + +## Aggregations + +```java +SearchRequest searchRequest = new SearchRequest.Builder().query(q -> q.match(m -> m.field("firstName") + .query(FieldValue.of("John")))) + .aggregations("firstNames", new Aggregation.Builder().terms(t -> t.field("firstName.keyword")) + .build()) + .build(); + +SearchResponse searchResponse = client.search(searchRequest, IndexData.class); +for (Map.Entry entry : searchResponse.aggregations().entrySet()) { + System.out.println("Agg - " + entry.getKey()); + entry.getValue().sterms().buckets().array().forEach(b -> System.out.printf("%s : %d%n", b.key(), b.docCount())); +} +``` + +## Delete the document + +The following sample code deletes a document whose ID is 1. + +```java +client.delete(d -> d.index(index).id("1")); +``` + +## Delete the index + +```java +DeleteIndexRequest deleteIndexRequest = new DeleteRequest.Builder().index(index).build(); +DeleteIndexResponse deleteIndexResponse = client.indices().delete(deleteIndexRequest); +``` \ No newline at end of file From 58cc30ddbe550a4a1e91169f2ca334bfc904dcb5 Mon Sep 17 00:00:00 2001 From: Abhinav Nath Date: Thu, 20 Oct 2022 17:23:56 +0530 Subject: [PATCH 03/16] Add DCO Signed-off-by: Abhinav Nath From 4c613a5df1e27e5e65d9e83942e4f0db0ee0bff4 Mon Sep 17 00:00:00 2001 From: Abhinav Nath Date: Thu, 20 Oct 2022 22:13:23 +0530 Subject: [PATCH 04/16] Add link to USER_GUIDE.md in README.md Signed-off-by: Abhinav Nath --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 127501e4e..75ec24889 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,9 @@ OpenSearch Java Client For more information, see [opensearch.org](https://opensearch.org/). This client is meant to replace the existing [OpenSearch Java High Level REST Client](https://opensearch.org/docs/latest/clients/java-rest-high-level/). +## Sample code + +Please see the [USER_GUIDE](USER_GUIDE.md) for code snippets. ## Project Resources From 1d7074fa1931f7a169492f06ad15076b9456ffda Mon Sep 17 00:00:00 2001 From: Harsha Vamsi Kalluri Date: Fri, 14 Oct 2022 07:47:22 -0700 Subject: [PATCH 05/16] Add changelog and changelog verifier (#239) Signed-off-by: Harsha Vamsi Kalluri Signed-off-by: Harsha Vamsi Kalluri Signed-off-by: Abhinav Nath --- .github/pull_request_template.md | 17 +++++++++++++++++ .github/workflows/changelog_verifier.yml | 18 ++++++++++++++++++ CHANGELOG.md | 19 +++++++++++++++++++ CONTRIBUTING.md | 18 ++++++++++++++++++ 4 files changed, 72 insertions(+) create mode 100644 .github/pull_request_template.md create mode 100644 .github/workflows/changelog_verifier.yml create mode 100644 CHANGELOG.md diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 000000000..fe308410b --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,17 @@ +### Description +[Describe what this change achieves] + +### Issues Resolved +[List any issues this PR will resolve] + +### Check List +- [ ] New functionality includes testing. + - [ ] All tests pass +- [ ] New functionality has been documented. + - [ ] New functionality has comments added + - [ ] New functionality is added to `docs` folder +- [ ] Commits are signed per the DCO using --signoff +- [ ] Commit changes are listed out in CHANGELOG.md file (See: [Changelog](https://github.com/opensearch-project/opensearch-java/blob/main/CONTRIBUTING.md#changelog)) + +By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license. +For more information on following Developer Certificate of Origin and signing off your commits, please check [here](https://github.com/opensearch-project/opensearch-java/blob/main/CONTRIBUTING.md#developer-certificate-of-origin). \ No newline at end of file diff --git a/.github/workflows/changelog_verifier.yml b/.github/workflows/changelog_verifier.yml new file mode 100644 index 000000000..96f99f17b --- /dev/null +++ b/.github/workflows/changelog_verifier.yml @@ -0,0 +1,18 @@ +name: "Changelog Verifier" +on: + pull_request: + types: [opened, edited, review_requested, synchronize, reopened, ready_for_review, labeled, unlabeled] + +jobs: + # Enforces the update of a changelog file on every pull request + verify-changelog: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + token: ${{ secrets.GITHUB_TOKEN }} + ref: ${{ github.event.pull_request.head.sha }} + + - uses: dangoslen/changelog-enforcer@v3 + with: + skipLabels: "autocut" diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 000000000..7480e177c --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,19 @@ +# CHANGELOG +Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) + +## [Unreleased] +### Added +- Github workflow for changelog verification ([#239](https://github.com/opensearch-project/opensearch-java/pull/239)) + +### Changed + +### Deprecated + +### Removed + +### Fixed + +### Security + + +[Unreleased]: https://github.com/opensearch-project/opensearch-java/compare/2.0...HEAD \ No newline at end of file diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 9638b01a2..9be415c08 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -5,6 +5,8 @@ - [Feature Requests](#feature-requests) - [Contributing Code](#contributing-code) - [Developer Certificate of Origin](#developer-certificate-of-origin) +- [Changelog](#changelog) + - [How to add my changes to CHANGELOG?](#how-to-add-my-changes-to-changelog) - [Review Process](#review-process) ## Contributing to OpenSearch @@ -80,6 +82,22 @@ Signed-off-by: Jane Smith You may type this line on your own when writing your commit messages. However, if your user.name and user.email are set in your git configs, you can use `-s` or `– – signoff` to add the `Signed-off-by` line to the end of the commit message. +## Changelog + +OpenSearch-Java maintains version specific changelog by enforcing a change to the ongoing [CHANGELOG](CHANGELOG.md) file adhering to the [Keep A Changelog](https://keepachangelog.com/en/1.0.0/) format. + +Briefly, the changes are curated by version, with the changes to the main branch added chronologically to `Unreleased` version. Further, each version has corresponding sections which list out the category of the change - `Added`, `Changed`, `Deprecated`, `Removed`, `Fixed`, `Security`. + + +### How to add my changes to [CHANGELOG](CHANGELOG.md)? + +As a contributor, you must ensure that every pull request has the changes listed out within the corresponding version and appropriate section of [CHANGELOG](CHANGELOG.md) file. + +Adding in the change is two step process - +1. Add your changes to the corresponding section within the CHANGELOG file with dummy pull request information, publish the PR + +2. Update the entry for your change in [`CHANGELOG.md`](CHANGELOG.md) and make sure that you reference the pull request there. + ## Review Process We deeply appreciate everyone who takes the time to make a contribution. We will review all contributions as quickly as possible. As a reminder, [opening an issue](https://github.com/opensearch-project/opensearch-java/issues/new/choose) discussing your change before you make it is the best way to smooth the PR process. This will prevent a rejection because someone else is already working on the problem, or because the solution is incompatible with the architectural direction. From ee7ed8f212e338188f6b09711592194c3382a2ef Mon Sep 17 00:00:00 2001 From: Meetesh Kumawat Date: Fri, 14 Oct 2022 22:56:05 +0530 Subject: [PATCH 06/16] Set javadoc encoding to utf-8 (#50) (#241) Signed-off-by: Meetesh Kumawat Signed-off-by: meetesh Signed-off-by: Meetesh Kumawat Signed-off-by: meetesh Signed-off-by: Abhinav Nath --- java-client/build.gradle.kts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/java-client/build.gradle.kts b/java-client/build.gradle.kts index abd053094..a70713129 100644 --- a/java-client/build.gradle.kts +++ b/java-client/build.gradle.kts @@ -74,6 +74,12 @@ tasks.withType { ) } +tasks.withType().configureEach{ + options { + encoding = "UTF-8" + } +} + tasks.withType { doFirst { if (rootProject.extra.has("gitHashFull")) { From ff30174c27c59b59a99cff73833b7d7449c579bb Mon Sep 17 00:00:00 2001 From: Andriy Redko Date: Fri, 14 Oct 2022 13:26:39 -0400 Subject: [PATCH 07/16] Update Jackson Databind to 2.13.4.2 (addressing CVE-2022-42003) (#240) Signed-off-by: Andriy Redko Signed-off-by: Andriy Redko Signed-off-by: Abhinav Nath --- java-client/build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/java-client/build.gradle.kts b/java-client/build.gradle.kts index a70713129..307c75393 100644 --- a/java-client/build.gradle.kts +++ b/java-client/build.gradle.kts @@ -139,7 +139,7 @@ dependencies { val opensearchVersion = "2.3.0" val jacksonVersion = "2.13.4" - val jacksonDatabindVersion = "2.13.4" + val jacksonDatabindVersion = "2.13.4.2" // Apache 2.0 implementation("org.opensearch.client", "opensearch-rest-client", opensearchVersion) From bac2e41f39311e9907fa1d16897a6e422f530df3 Mon Sep 17 00:00:00 2001 From: Harsha Vamsi Kalluri Date: Tue, 18 Oct 2022 17:47:23 -0700 Subject: [PATCH 08/16] Updates changelog for dependabot PRs (#247) * Updates changelog for dependabot PRs Signed-off-by: Harsha Vamsi Kalluri * Adding dependabot label for workflow Signed-off-by: Harsha Vamsi Kalluri Signed-off-by: Harsha Vamsi Kalluri Signed-off-by: Abhinav Nath --- .github/dependabot.yml | 6 +++++ .github/workflows/dependabot_pr.yml | 37 +++++++++++++++++++++++++++++ CHANGELOG.md | 1 + 3 files changed, 44 insertions(+) create mode 100644 .github/workflows/dependabot_pr.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 33c36760d..db3ca4985 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -4,9 +4,15 @@ updates: package-ecosystem: gradle schedule: interval: weekly + labels: + - "dependabot" + - "dependencies" - directory: /java-client/ open-pull-requests-limit: 1 package-ecosystem: gradle schedule: interval: weekly + labels: + - "dependabot" + - "dependencies" version: 2 diff --git a/.github/workflows/dependabot_pr.yml b/.github/workflows/dependabot_pr.yml new file mode 100644 index 000000000..f13889c13 --- /dev/null +++ b/.github/workflows/dependabot_pr.yml @@ -0,0 +1,37 @@ +name: Dependabot PR actions +on: pull_request + +jobs: + dependabot: + runs-on: ubuntu-latest + permissions: + pull-requests: write + contents: write + if: ${{ github.actor == 'dependabot[bot]' }} + steps: + - name: GitHub App token + id: github_app_token + uses: tibdex/github-app-token@v1.5.0 + with: + app_id: ${{ secrets.APP_ID }} + private_key: ${{ secrets.APP_PRIVATE_KEY }} + installation_id: 22958780 + + - name: Check out code + uses: actions/checkout@v2 + with: + token: ${{ steps.github_app_token.outputs.token }} + + - name: Update the changelog + uses: dangoslen/dependabot-changelog-helper@v1 + with: + version: 'Unreleased' + + - name: Commit the changes + uses: stefanzweifel/git-auto-commit-action@v4 + with: + commit_message: "Update changelog" + branch: ${{ github.head_ref }} + commit_user_name: dependabot[bot] + commit_user_email: support@github.com + commit_options: '--signoff' \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 7480e177c..d2abf5254 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) ## [Unreleased] ### Added - Github workflow for changelog verification ([#239](https://github.com/opensearch-project/opensearch-java/pull/239)) +- Github workflow for dependabot PRs ([#247](https://github.com/opensearch-project/opensearch-java/pull/247)) ### Changed From 9f1e54bb4e26edfe2e43669a273d7172194c3b3c Mon Sep 17 00:00:00 2001 From: Andriy Redko Date: Tue, 18 Oct 2022 20:47:39 -0400 Subject: [PATCH 09/16] Update tests to use JUnit's Assert (#244) Signed-off-by: Andriy Redko Signed-off-by: Andriy Redko Signed-off-by: Abhinav Nath --- CHANGELOG.md | 1 + .../integTest/aws/AwsSdk2BulkRequestIT.java | 6 ++--- .../integTest/aws/AwsSdk2SearchIT.java | 22 +++++++++---------- 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d2abf5254..b7ddacf1e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) - Github workflow for dependabot PRs ([#247](https://github.com/opensearch-project/opensearch-java/pull/247)) ### Changed +- Update tests to use JUnit's Assert ([#244]https://github.com/opensearch-project/opensearch-java/pull/244) ### Deprecated diff --git a/java-client/src/test/java/org/opensearch/client/opensearch/integTest/aws/AwsSdk2BulkRequestIT.java b/java-client/src/test/java/org/opensearch/client/opensearch/integTest/aws/AwsSdk2BulkRequestIT.java index 85fcb75a5..36672582a 100644 --- a/java-client/src/test/java/org/opensearch/client/opensearch/integTest/aws/AwsSdk2BulkRequestIT.java +++ b/java-client/src/test/java/org/opensearch/client/opensearch/integTest/aws/AwsSdk2BulkRequestIT.java @@ -9,7 +9,7 @@ package org.opensearch.client.opensearch.integTest.aws; import org.junit.Test; -import org.locationtech.jts.util.Assert; +import org.junit.Assert; import org.opensearch.client.opensearch.OpenSearchClient; import org.opensearch.client.opensearch._types.Refresh; import org.opensearch.client.opensearch._types.query_dsl.Query; @@ -49,7 +49,7 @@ public void testBulkRequest() throws Exception { .operations(ops) .refresh(Refresh.WaitFor); BulkResponse bulkResponse = client.bulk(bulkReq.build()); - Assert.equals(3, bulkResponse.items().size()); + Assert.assertEquals(3, bulkResponse.items().size()); Query query = Query.of(qb -> qb.match(mb -> mb.field("title").query(fv -> fv.stringValue("Document")))); final SearchRequest.Builder searchReq = new SearchRequest.Builder() @@ -60,6 +60,6 @@ public void testBulkRequest() throws Exception { .ignoreThrottled(false) .query(query); SearchResponse searchResponse = client.search(searchReq.build(), SimplePojo.class); - Assert.equals(3, searchResponse.hits().hits().size()); + Assert.assertEquals(3, searchResponse.hits().hits().size()); } } diff --git a/java-client/src/test/java/org/opensearch/client/opensearch/integTest/aws/AwsSdk2SearchIT.java b/java-client/src/test/java/org/opensearch/client/opensearch/integTest/aws/AwsSdk2SearchIT.java index f81c84ccb..b138ff854 100644 --- a/java-client/src/test/java/org/opensearch/client/opensearch/integTest/aws/AwsSdk2SearchIT.java +++ b/java-client/src/test/java/org/opensearch/client/opensearch/integTest/aws/AwsSdk2SearchIT.java @@ -9,7 +9,7 @@ package org.opensearch.client.opensearch.integTest.aws; import org.junit.Test; -import org.locationtech.jts.util.Assert; +import org.junit.Assert; import org.opensearch.client.opensearch.OpenSearchAsyncClient; import org.opensearch.client.opensearch.OpenSearchClient; import org.opensearch.client.opensearch._types.OpType; @@ -55,18 +55,18 @@ void testClient(boolean async) throws Exception { addDoc(client, "id3", doc3, true); SearchResponse response = query(client, "NotPresent", null); - Assert.equals(0, response.hits().hits().size()); + Assert.assertEquals(0, response.hits().hits().size()); response = query(client, "Document", null); - Assert.equals(3, response.hits().hits().size()); + Assert.assertEquals(3, response.hits().hits().size()); response = query(client, "1", null); - Assert.equals(1, response.hits().hits().size()); - Assert.equals(doc1, response.hits().hits().get(0).source()); + Assert.assertEquals(1, response.hits().hits().size()); + Assert.assertEquals(doc1, response.hits().hits().get(0).source()); response = query(client, null, "wait"); - Assert.equals(1, response.hits().hits().size()); - Assert.equals(doc3, response.hits().hits().get(0).source()); + Assert.assertEquals(1, response.hits().hits().size()); + Assert.assertEquals(doc3, response.hits().hits().get(0).source()); } void testClientAsync(boolean async) throws Exception { @@ -93,14 +93,14 @@ void testClientAsync(boolean async) throws Exception { }).get(); SearchResponse response = results.get(0); - Assert.equals(0, response.hits().hits().size()); + Assert.assertEquals(0, response.hits().hits().size()); response = results.get(1); - Assert.equals(3, response.hits().hits().size()); + Assert.assertEquals(3, response.hits().hits().size()); response = results.get(2); - Assert.equals(1, response.hits().hits().size()); - Assert.equals(doc1, response.hits().hits().get(0).source()); + Assert.assertEquals(1, response.hits().hits().size()); + Assert.assertEquals(doc1, response.hits().hits().get(0).source()); } From da20ae51612d1892f7692f2644c44a340663b916 Mon Sep 17 00:00:00 2001 From: Harsha Vamsi Kalluri Date: Wed, 19 Oct 2022 10:31:58 -0700 Subject: [PATCH 10/16] Update literature around changelog (#242) * Update literature Signed-off-by: Harsha Vamsi Kalluri * Removing pr template and updating language Signed-off-by: Harsha Vamsi Kalluri Signed-off-by: Harsha Vamsi Kalluri Co-authored-by: Daniel (dB.) Doubrovkine Signed-off-by: Abhinav Nath --- .github/pull_request_template.md | 17 ----------------- CHANGELOG.md | 1 + CONTRIBUTING.md | 14 +++++++------- 3 files changed, 8 insertions(+), 24 deletions(-) delete mode 100644 .github/pull_request_template.md diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md deleted file mode 100644 index fe308410b..000000000 --- a/.github/pull_request_template.md +++ /dev/null @@ -1,17 +0,0 @@ -### Description -[Describe what this change achieves] - -### Issues Resolved -[List any issues this PR will resolve] - -### Check List -- [ ] New functionality includes testing. - - [ ] All tests pass -- [ ] New functionality has been documented. - - [ ] New functionality has comments added - - [ ] New functionality is added to `docs` folder -- [ ] Commits are signed per the DCO using --signoff -- [ ] Commit changes are listed out in CHANGELOG.md file (See: [Changelog](https://github.com/opensearch-project/opensearch-java/blob/main/CONTRIBUTING.md#changelog)) - -By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license. -For more information on following Developer Certificate of Origin and signing off your commits, please check [here](https://github.com/opensearch-project/opensearch-java/blob/main/CONTRIBUTING.md#developer-certificate-of-origin). \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index b7ddacf1e..b8de97615 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) - Github workflow for dependabot PRs ([#247](https://github.com/opensearch-project/opensearch-java/pull/247)) ### Changed +- Update literature around changelog contributions in CONTRIBUTING.md ([#242](https://github.com/opensearch-project/opensearch-java/pull/242)) - Update tests to use JUnit's Assert ([#244]https://github.com/opensearch-project/opensearch-java/pull/244) ### Deprecated diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 9be415c08..36bc8c071 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -6,7 +6,7 @@ - [Contributing Code](#contributing-code) - [Developer Certificate of Origin](#developer-certificate-of-origin) - [Changelog](#changelog) - - [How to add my changes to CHANGELOG?](#how-to-add-my-changes-to-changelog) + - [Adding Changes](#adding-changes) - [Review Process](#review-process) ## Contributing to OpenSearch @@ -84,17 +84,17 @@ You may type this line on your own when writing your commit messages. However, i ## Changelog -OpenSearch-Java maintains version specific changelog by enforcing a change to the ongoing [CHANGELOG](CHANGELOG.md) file adhering to the [Keep A Changelog](https://keepachangelog.com/en/1.0.0/) format. +OpenSearch-java maintains a version specific changelog by enforcing a change to the ongoing [CHANGELOG](CHANGELOG.md) file adhering to the [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) format. -Briefly, the changes are curated by version, with the changes to the main branch added chronologically to `Unreleased` version. Further, each version has corresponding sections which list out the category of the change - `Added`, `Changed`, `Deprecated`, `Removed`, `Fixed`, `Security`. +The changes are curated by version, with the changes to the main branch added chronologically to the `Unreleased` version. Each version has corresponding sections which list out the category of the change - `Added`, `Changed`, `Deprecated`, `Removed`, `Fixed`, `Security`. -### How to add my changes to [CHANGELOG](CHANGELOG.md)? +### Adding Changes -As a contributor, you must ensure that every pull request has the changes listed out within the corresponding version and appropriate section of [CHANGELOG](CHANGELOG.md) file. +As a contributor, you must ensure that every pull request has its changes listed out within the corresponding version and appropriate section of the [CHANGELOG](CHANGELOG.md) file. -Adding in the change is two step process - -1. Add your changes to the corresponding section within the CHANGELOG file with dummy pull request information, publish the PR +Adding in the change is a two step process - +1. Add your changes to the corresponding section within the CHANGELOG file with dummy pull request information, publish the PR. 2. Update the entry for your change in [`CHANGELOG.md`](CHANGELOG.md) and make sure that you reference the pull request there. From 9db6c5c4bd4d30fffa886d5f2aad4d2961dbe6d3 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 20 Oct 2022 12:32:48 -0700 Subject: [PATCH 11/16] Bump grgit-gradle from 4.0.1 to 5.0.0 (#243) * Bump grgit-gradle from 4.0.1 to 5.0.0 Bumps [grgit-gradle](https://github.com/ajoberstar/grgit) from 4.0.1 to 5.0.0. - [Release notes](https://github.com/ajoberstar/grgit/releases) - [Commits](https://github.com/ajoberstar/grgit/compare/4.0.1...5.0.0) --- updated-dependencies: - dependency-name: org.ajoberstar.grgit:grgit-gradle dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] * Update changelog Signed-off-by: dependabot[bot] Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: dependabot[bot] Signed-off-by: Abhinav Nath --- CHANGELOG.md | 2 ++ buildSrc/build.gradle.kts | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b8de97615..708c0eed4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,8 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) ### Added - Github workflow for changelog verification ([#239](https://github.com/opensearch-project/opensearch-java/pull/239)) - Github workflow for dependabot PRs ([#247](https://github.com/opensearch-project/opensearch-java/pull/247)) +### Dependencies +- Bumps `grgit-gradle` from 4.0.1 to 5.0.0 ### Changed - Update literature around changelog contributions in CONTRIBUTING.md ([#242](https://github.com/opensearch-project/opensearch-java/pull/242)) diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts index c82bb73f9..81e081c05 100644 --- a/buildSrc/build.gradle.kts +++ b/buildSrc/build.gradle.kts @@ -31,7 +31,7 @@ */ dependencies { - implementation("org.ajoberstar.grgit:grgit-gradle:4.0.1") + implementation("org.ajoberstar.grgit:grgit-gradle:5.0.0") } repositories { From b94820eb29c2fa13fb8295270b9efad016ffe8b2 Mon Sep 17 00:00:00 2001 From: Abhinav Nath Date: Thu, 20 Oct 2022 17:23:56 +0530 Subject: [PATCH 12/16] Add DCO Signed-off-by: Abhinav Nath From c36dbeb171894539521b7e695a80e87d417b57f3 Mon Sep 17 00:00:00 2001 From: Abhinav Nath Date: Fri, 21 Oct 2022 12:51:47 +0530 Subject: [PATCH 13/16] Update CHANGELOG and README Signed-off-by: Abhinav Nath --- CHANGELOG.md | 5 ++++- README.md | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 708c0eed4..c5fc451ec 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,12 +5,15 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) ### Added - Github workflow for changelog verification ([#239](https://github.com/opensearch-project/opensearch-java/pull/239)) - Github workflow for dependabot PRs ([#247](https://github.com/opensearch-project/opensearch-java/pull/247)) +- Github workflow for dependabot PRs ([#234](https://github.com/opensearch-project/opensearch-java/pull/234)) + ### Dependencies - Bumps `grgit-gradle` from 4.0.1 to 5.0.0 ### Changed - Update literature around changelog contributions in CONTRIBUTING.md ([#242](https://github.com/opensearch-project/opensearch-java/pull/242)) -- Update tests to use JUnit's Assert ([#244]https://github.com/opensearch-project/opensearch-java/pull/244) +- Update tests to use JUnit's Assert ([#244](https://github.com/opensearch-project/opensearch-java/pull/244)) +- Add support to parse sub-aggregations from filter/nested aggregations ([#234](https://github.com/opensearch-project/opensearch-java/pull/234)) ### Deprecated diff --git a/README.md b/README.md index 75ec24889..66256a905 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,7 @@ OpenSearch Java Client - [Welcome!](#welcome) +- [Sample code](#sample-code) - [Project Resources](#project-resources) - [Code of Conduct](#code-of-conduct) - [Compatibility with OpenSearch](#compatibility-with-opensearch) From b0d205ad79be393229642566d9cb16876553664c Mon Sep 17 00:00:00 2001 From: Abhinav Nath Date: Thu, 20 Oct 2022 17:23:56 +0530 Subject: [PATCH 14/16] Add DCO Signed-off-by: Abhinav Nath From 4bd4a43b70ffbec759703036a7fc3936cb01404f Mon Sep 17 00:00:00 2001 From: Abhinav Nath Date: Thu, 20 Oct 2022 17:23:56 +0530 Subject: [PATCH 15/16] Add DCO Signed-off-by: Abhinav Nath From 707d6b32dd489303f8b88d6003bf90856115baeb Mon Sep 17 00:00:00 2001 From: Abhinav Nath Date: Fri, 21 Oct 2022 22:19:40 +0530 Subject: [PATCH 16/16] Fix CHANGLOG and README TOC Signed-off-by: Abhinav Nath --- CHANGELOG.md | 1 - README.md | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c5fc451ec..90e65f899 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,6 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) ### Added - Github workflow for changelog verification ([#239](https://github.com/opensearch-project/opensearch-java/pull/239)) - Github workflow for dependabot PRs ([#247](https://github.com/opensearch-project/opensearch-java/pull/247)) -- Github workflow for dependabot PRs ([#234](https://github.com/opensearch-project/opensearch-java/pull/234)) ### Dependencies - Bumps `grgit-gradle` from 4.0.1 to 5.0.0 diff --git a/README.md b/README.md index 66256a905..01a56c28a 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ OpenSearch Java Client - [Welcome!](#welcome) -- [Sample code](#sample-code) +- [Sample Code](#sample-code) - [Project Resources](#project-resources) - [Code of Conduct](#code-of-conduct) - [Compatibility with OpenSearch](#compatibility-with-opensearch) @@ -24,7 +24,7 @@ OpenSearch Java Client For more information, see [opensearch.org](https://opensearch.org/). This client is meant to replace the existing [OpenSearch Java High Level REST Client](https://opensearch.org/docs/latest/clients/java-rest-high-level/). -## Sample code +## Sample Code Please see the [USER_GUIDE](USER_GUIDE.md) for code snippets.