Skip to content

Commit

Permalink
Merge branch '2.x' into backport/backport-850-to-2.x
Browse files Browse the repository at this point in the history
Signed-off-by: Varun Jain <[email protected]>
  • Loading branch information
vibrantvarun committed Feb 21, 2024
2 parents 60f80d8 + 7acd729 commit 4f02c84
Show file tree
Hide file tree
Showing 70 changed files with 313 additions and 56 deletions.
15 changes: 14 additions & 1 deletion .github/workflows/test-unit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
java: [ 11, 17, 21 ]
java: [ 8, 11, 17, 21 ]
os: [ubuntu-latest, windows-latest, macOS-latest]
steps:
- name: Checkout Java Client
Expand All @@ -21,4 +21,17 @@ jobs:
cache: 'gradle'

- name: Run Unit Test
if: ${{ matrix.java != 8 }}
run: ./gradlew clean unitTest

- name: Set up JDK 11
uses: actions/setup-java@v3
if: ${{ matrix.java == 8 }}
with:
java-version: 11
distribution: 'temurin'
cache: 'gradle'

- name: Run Unit Test
if: ${{ matrix.java == 8 }}
run: ./gradlew clean unitTest -D"runtime.java=8"
24 changes: 21 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,23 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)

## [Unreleased 2.x]
### Added

### Dependencies
- Bumps `org.ajoberstar.grgit:grgit-gradle` from 5.2.0 to 5.2.2

### Changed

### Deprecated

### Removed

### Fixed
- Fix missing properties on UpdateOperation ([#744](https://github.com/opensearch-project/opensearch-java/pull/744))

### Security

## [2.8.4] - 02/20/2024
### Added
- Add search role type for nodes in cluster stats ([#848](https://github.com/opensearch-project/opensearch-java/pull/848))
- Add support for Hybrid query type ([#850](https://github.com/opensearch-project/opensearch-java/pull/850))

Expand All @@ -17,8 +34,6 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
### Fixed
- Fix ClusterStatsResponse field deserialization ([#848](https://github.com/opensearch-project/opensearch-java/pull/848))

### Security

## [2.8.3] - 02/12/2024
### Added

Expand Down Expand Up @@ -70,6 +85,8 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
### Dependencies

### Changed
- Restore support for Java 8 ([#767](https://github.com/opensearch-project/opensearch-java/pull/767))
- Add an integration test that runs on JDK-8 ([#795](https://github.com/opensearch-project/opensearch-java/pull/795))

### Deprecated

Expand Down Expand Up @@ -272,7 +289,8 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)

### Security

[Unreleased 2.x]: https://github.com/opensearch-project/opensearch-java/compare/v2.8.3...2.x
[Unreleased 2.x]: https://github.com/opensearch-project/opensearch-java/compare/v2.8.4...2.x
[2.8.4]: https://github.com/opensearch-project/opensearch-java/compare/v2.8.3...v2.8.4
[2.8.3]: https://github.com/opensearch-project/opensearch-java/compare/v2.8.2...v2.8.3
[2.8.2]: https://github.com/opensearch-project/opensearch-java/compare/v2.8.1...v2.8.2
[2.8.1]: https://github.com/opensearch-project/opensearch-java/compare/v2.8.0...v2.8.1
Expand Down
2 changes: 1 addition & 1 deletion COMPATIBILITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ The below matrix shows the compatibility of the [`opensearch-java-client`](https
| Client Version | JDK |
|----------------|--------------------|
| 1.0.0 | 8 |
| 2.x.0 | 11 / 17 / 21 |
| 2.x.0 | 8 / 11 / 17 / 21 |

## Upgrading

Expand Down
2 changes: 1 addition & 1 deletion buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
*/

dependencies {
implementation("org.ajoberstar.grgit:grgit-gradle:5.2.0")
implementation("org.ajoberstar.grgit:grgit-gradle:5.2.2")
}

repositories {
Expand Down
62 changes: 56 additions & 6 deletions java-client/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

import com.github.jk1.license.ProjectData
import com.github.jk1.license.render.ReportRenderer
import org.gradle.api.tasks.testing.Test
import java.io.FileWriter

buildscript {
Expand Down Expand Up @@ -60,16 +61,27 @@ configurations {
}
}

val runtimeJavaVersion = (System.getProperty("runtime.java")?.toInt())?.let(JavaVersion::toVersion) ?: JavaVersion.current()
logger.quiet("=======================================")
logger.quiet(" Runtime JDK Version : " + runtimeJavaVersion)
logger.quiet(" Gradle JDK Version : " + JavaVersion.current())
logger.quiet("=======================================")

java {
targetCompatibility = JavaVersion.VERSION_11
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_1_8
sourceCompatibility = JavaVersion.VERSION_1_8

withJavadocJar()
withSourcesJar()

registerFeature("awsSdk2Support") {
usingSourceSet(sourceSets.get("main"))
}

toolchain {
languageVersion = JavaLanguageVersion.of(runtimeJavaVersion.majorVersion)
vendor = JvmVendorSpec.ADOPTIUM
}
}

tasks.withType<ProcessResources> {
Expand Down Expand Up @@ -146,15 +158,19 @@ val integrationTest = task<Test>("integrationTest") {
System.getProperty("tests.awsSdk2support.domainRegion", "us-east-1"))
}

val opensearchVersion = "2.12.0"

dependencies {

val opensearchVersion = "2.7.0"
val jacksonVersion = "2.15.2"
val jacksonDatabindVersion = "2.15.2"
val jacksonVersion = "2.16.1"
val jacksonDatabindVersion = "2.16.1"

// Apache 2.0
implementation("org.opensearch.client", "opensearch-rest-client", opensearchVersion)
testImplementation("org.opensearch.test", "framework", opensearchVersion)
testImplementation("org.hamcrest:hamcrest:2.2")
testImplementation("com.carrotsearch.randomizedtesting:randomizedtesting-runner:2.8.1") {
exclude(group = "junit")
}

// Apache 2.0
// https://search.maven.org/artifact/com.google.code.findbugs/jsr305
Expand Down Expand Up @@ -327,3 +343,37 @@ publishing {
}
}
}

if (runtimeJavaVersion >= JavaVersion.VERSION_11) {
val java11: SourceSet = sourceSets.create("java11") {
java {
compileClasspath += sourceSets.main.get().output + sourceSets.test.get().output
runtimeClasspath += sourceSets.main.get().output + sourceSets.test.get().output
srcDir("src/test/java11")
}
}

configurations[java11.implementationConfigurationName].extendsFrom(configurations.testImplementation.get())
configurations[java11.runtimeOnlyConfigurationName].extendsFrom(configurations.testRuntimeOnly.get())

dependencies {
testImplementation("org.opensearch.test", "framework", opensearchVersion) {
exclude(group = "org.hamcrest")
}
}

tasks.named<JavaCompile>("compileJava11Java") {
targetCompatibility = JavaVersion.VERSION_11.toString()
sourceCompatibility = JavaVersion.VERSION_11.toString()
}

tasks.named<JavaCompile>("compileTestJava") {
targetCompatibility = JavaVersion.VERSION_11.toString()
sourceCompatibility = JavaVersion.VERSION_11.toString()
}

tasks.test {
testClassesDirs += java11.output.classesDirs
classpath = sourceSets["java11"].runtimeClasspath
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,12 @@ public static class Builder<TDocument> extends BulkOperationBase.AbstractBuilder
@Nullable
private Boolean docAsUpsert;

@Nullable
private Boolean scriptedUpsert;

@Nullable
private Boolean detectNoop;

@Nullable
private TDocument upsert;

Expand All @@ -166,6 +172,22 @@ public final Builder<TDocument> docAsUpsert(@Nullable Boolean value) {
return this;
}

/**
* API name: {@code scripted_upsert}
*/
public final Builder<TDocument> scriptedUpsert(@Nullable Boolean value) {
this.scriptedUpsert = value;
return this;
}

/**
* API name: {@code detect_noop}
*/
public final Builder<TDocument> detectNoop(@Nullable Boolean value) {
this.detectNoop = value;
return this;
}

/**
* API name: {@code upsert}
*/
Expand Down Expand Up @@ -223,6 +245,8 @@ public UpdateOperation<TDocument> build() {

data = new UpdateOperationData.Builder<TDocument>().document(document)
.docAsUpsert(docAsUpsert)
.scriptedUpsert(scriptedUpsert)
.detectNoop(detectNoop)
.script(script)
.upsert(upsert)
.tDocumentSerializer(tDocumentSerializer)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ public class UpdateOperationData<TDocument> implements JsonpSerializable {
@Nullable
private final Boolean docAsUpsert;

@Nullable
private final Boolean scriptedUpsert;

@Nullable
private final Boolean detectNoop;

@Nullable
private final TDocument upsert;

Expand All @@ -36,6 +42,8 @@ public class UpdateOperationData<TDocument> implements JsonpSerializable {
private UpdateOperationData(Builder<TDocument> builder) {
this.document = builder.document;
this.docAsUpsert = builder.docAsUpsert;
this.scriptedUpsert = builder.scriptedUpsert;
this.detectNoop = builder.detectNoop;
this.script = builder.script;
this.upsert = builder.upsert;
this.tDocumentSerializer = builder.tDocumentSerializer;
Expand All @@ -55,6 +63,16 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {
generator.write(this.docAsUpsert);
}

if (this.scriptedUpsert != null) {
generator.writeKey("scripted_upsert");
generator.write(scriptedUpsert);
}

if (this.detectNoop != null) {
generator.writeKey("detect_noop");
generator.write(detectNoop);
}

if (this.document != null) {
generator.writeKey("doc");
JsonpUtils.serialize(document, generator, tDocumentSerializer, mapper);
Expand Down Expand Up @@ -87,6 +105,12 @@ public static class Builder<TDocument> extends BulkOperationBase.AbstractBuilder
@Nullable
private Boolean docAsUpsert;

@Nullable
private Boolean scriptedUpsert;

@Nullable
private Boolean detectNoop;

@Nullable
private TDocument upsert;

Expand All @@ -109,6 +133,22 @@ public final Builder<TDocument> docAsUpsert(@Nullable Boolean value) {
return this;
}

/**
* API name: {@code scripted_upsert}
*/
public final Builder<TDocument> scriptedUpsert(@Nullable Boolean value) {
this.scriptedUpsert = value;
return this;
}

/**
* API name: {@code detect_noop}
*/
public final Builder<TDocument> detectNoop(@Nullable Boolean value) {
this.detectNoop = value;
return this;
}

/**
* API name: {@code upsert}
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.opensearch.client.opensearch._types.query_dsl;

import java.util.List;
import java.util.Collections;
import org.junit.Test;
import org.opensearch.client.opensearch._types.GeoLocation;
import org.opensearch.client.opensearch.model.ModelTestCase;
Expand All @@ -9,7 +9,7 @@ public class GeoDistanceQueryTest extends ModelTestCase {
@Test
public void toBuilder() {
GeoDistanceQuery origin = new GeoDistanceQuery.Builder().field("field")
.location(new GeoLocation.Builder().coords(List.of(1.0)).build())
.location(new GeoLocation.Builder().coords(Collections.singletonList(1.0)).build())
.build();
GeoDistanceQuery copied = origin.toBuilder().build();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package org.opensearch.client.opensearch._types.query_dsl;

import java.util.List;
import java.util.Collections;
import org.junit.Test;
import org.opensearch.client.opensearch._types.FieldValue;
import org.opensearch.client.opensearch.model.ModelTestCase;

public class PinnedQueryTest extends ModelTestCase {
@Test
public void toBuilder() {
PinnedQuery origin = new PinnedQuery.Builder().organic(buildDummyQuery()).ids(List.of("1")).build();
PinnedQuery origin = new PinnedQuery.Builder().organic(buildDummyQuery()).ids(Collections.singletonList("1")).build();
PinnedQuery copied = origin.toBuilder().build();

assertEquals(toJson(copied), toJson(origin));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
package org.opensearch.client.opensearch._types.query_dsl;

import java.util.List;
import java.util.Collections;
import org.junit.Test;
import org.opensearch.client.opensearch.model.ModelTestCase;

public class SpanContainingQueryTest extends ModelTestCase {
@Test
public void toBuilder() {
SpanContainingQuery origin = new SpanContainingQuery.Builder().big(
new SpanQuery.Builder().spanOr(new SpanOrQuery.Builder().clauses(List.of()).build()).build()
).little(new SpanQuery.Builder().spanOr(new SpanOrQuery.Builder().clauses(List.of()).build()).build()).build();
new SpanQuery.Builder().spanOr(new SpanOrQuery.Builder().clauses(Collections.emptyList()).build()).build()
).little(new SpanQuery.Builder().spanOr(new SpanOrQuery.Builder().clauses(Collections.emptyList()).build()).build()).build();
SpanContainingQuery copied = origin.toBuilder().build();

assertEquals(toJson(copied), toJson(origin));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package org.opensearch.client.opensearch._types.query_dsl;

import java.util.List;
import java.util.Collections;
import org.junit.Test;
import org.opensearch.client.opensearch.model.ModelTestCase;

public class SpanFieldMaskingQueryTest extends ModelTestCase {
@Test
public void toBuilder() {
SpanFieldMaskingQuery origin = new SpanFieldMaskingQuery.Builder().field("field")
.query(new SpanQuery.Builder().spanOr(new SpanOrQuery.Builder().clauses(List.of()).build()).build())
.query(new SpanQuery.Builder().spanOr(new SpanOrQuery.Builder().clauses(Collections.emptyList()).build()).build())
.build();
SpanFieldMaskingQuery copied = origin.toBuilder().build();

Expand Down
Loading

0 comments on commit 4f02c84

Please sign in to comment.