diff --git a/CHANGELOG.md b/CHANGELOG.md index 46bc5b3730..8f4622930e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,7 @@ This section is for maintaining a changelog for all breaking changes for the cli ### Changed - Migrate client transports to Apache HttpClient / Core 5.x ([#246](https://github.com/opensearch-project/opensearch-java/pull/246)) +- Changed SearchAfter of SearchRequest type to FieldValue instead of String ([#769](https://github.com/opensearch-project/opensearch-java/pull/769)) ### Deprecated - Deprecate RestClientTransport ([#536](https://github.com/opensearch-project/opensearch-java/pull/536)) diff --git a/UPGRADING.md b/UPGRADING.md new file mode 100644 index 0000000000..4e437fa770 --- /dev/null +++ b/UPGRADING.md @@ -0,0 +1,20 @@ +# UPGRADING + +## [UPGRADING 2.x to 3.0] +### SearchAfter of SearchRequest type +- Changed SearchAfter of SearchRequest type to FieldValue instead of String ([#769](https://github.com/opensearch-project/opensearch-java/pull/769)) +- Consider using `FieldValue.of` to make string type values compatible. + +Before: +``` +.searchAfter("string") +.searchAfter("string1", "string2") +.searchAfter(List.of("String")) +``` + +After: +``` +.searchAfter(FieldValue.of("string")) +.searchAfter(FieldValue.of("string1"), FieldValue.of("string2")) +.searchAfter(List.of(FieldValue.of("String"))) +``` diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/core/SearchRequest.java b/java-client/src/main/java/org/opensearch/client/opensearch/core/SearchRequest.java index 852415b0a2..f88b8f99ca 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/core/SearchRequest.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/core/SearchRequest.java @@ -47,6 +47,7 @@ import org.opensearch.client.json.ObjectDeserializer; import org.opensearch.client.opensearch._types.ErrorResponse; import org.opensearch.client.opensearch._types.ExpandWildcard; +import org.opensearch.client.opensearch._types.FieldValue; import org.opensearch.client.opensearch._types.RequestBase; import org.opensearch.client.opensearch._types.ScriptField; import org.opensearch.client.opensearch._types.SearchType; @@ -184,7 +185,7 @@ public class SearchRequest extends RequestBase implements JsonpSerializable { @Nullable private final Time scroll; - private final List searchAfter; + private final List searchAfter; @Nullable private final SearchType searchType; @@ -678,7 +679,7 @@ public final Time scroll() { /** * API name: {@code search_after} */ - public final List searchAfter() { + public final List searchAfter() { return this.searchAfter; } @@ -966,8 +967,8 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { if (ApiTypeHelper.isDefined(this.searchAfter)) { generator.writeKey("search_after"); generator.writeStartArray(); - for (String item0 : this.searchAfter) { - generator.write(item0); + for (FieldValue item0 : this.searchAfter) { + item0.serialize(generator, mapper); } generator.writeEnd(); @@ -1173,7 +1174,7 @@ public static class Builder extends ObjectBuilderBase implements ObjectBuilder searchAfter; + private List searchAfter; @Nullable private SearchType searchType; @@ -1860,7 +1861,7 @@ public final Builder scroll(Function> fn) { *

* Adds all elements of list to searchAfter. */ - public final Builder searchAfter(List list) { + public final Builder searchAfter(List list) { this.searchAfter = _listAddAll(this.searchAfter, list); return this; } @@ -1870,7 +1871,7 @@ public final Builder searchAfter(List list) { *

* Adds one or more values to searchAfter. */ - public final Builder searchAfter(String value, String... values) { + public final Builder searchAfter(FieldValue value, FieldValue... values) { this.searchAfter = _listAdd(this.searchAfter, value, values); return this; } @@ -2142,7 +2143,7 @@ protected static void setupSearchRequestDeserializer(ObjectDeserializer