From 53081454cdeb41ba31274265aec4b6b2d3249f24 Mon Sep 17 00:00:00 2001 From: Thomas Farr Date: Thu, 10 Oct 2024 10:45:55 +1300 Subject: [PATCH] Change sort and searchAfter to List Signed-off-by: Thomas Farr --- CHANGELOG.md | 2 ++ .../core/msearch/MultisearchBody.java | 17 +++++++++-------- .../client/opensearch/core/search/Hit.java | 17 +++++++++-------- 3 files changed, 20 insertions(+), 16 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4d0512de31..1efb757745 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,8 @@ This section is for maintaining a changelog for all breaking changes for the cli - Changed type of `DanglingIndex`'s `creationDateMillis` field from `String` to `long` ([#1124](https://github.com/opensearch-project/opensearch-java/pull/1124)) - Changed type of `ShardStatistics`'s `total`, `successful`, `failed` & `skipped` fields from `Number` to `int/Integer` ([#1158](https://github.com/opensearch-project/opensearch-java/pull/1158)) - Unified `tasks.Info` and `tasks.State` classes into `tasks.TaskInfo` ([#1187](https://github.com/opensearch-project/opensearch-java/pull/1187)) +- Changed type of `Hit`'s `sort` field from `List` to `List` ([]()) +- Changed type of `MultisearchBody`'s `searchAfter` field from `List` to `List` ([]()) ### Deprecated - Deprecate RestClientTransport ([#536](https://github.com/opensearch-project/opensearch-java/pull/536)) diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/core/msearch/MultisearchBody.java b/java-client/src/main/java/org/opensearch/client/opensearch/core/msearch/MultisearchBody.java index fb4ff1013d..4ab4787a96 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/core/msearch/MultisearchBody.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/core/msearch/MultisearchBody.java @@ -44,6 +44,7 @@ import org.opensearch.client.json.ObjectBuilderDeserializer; import org.opensearch.client.json.ObjectDeserializer; import org.opensearch.client.json.PlainJsonSerializable; +import org.opensearch.client.opensearch._types.FieldValue; import org.opensearch.client.opensearch._types.ScriptField; import org.opensearch.client.opensearch._types.SortOptions; import org.opensearch.client.opensearch._types.aggregations.Aggregation; @@ -77,7 +78,7 @@ public class MultisearchBody implements PlainJsonSerializable { @Nullable private final Query postFilter; - private final List searchAfter; + private final List searchAfter; @Nullable private final Integer size; @@ -202,7 +203,7 @@ public final Query postFilter() { /** * API name: {@code search_after} */ - public final List searchAfter() { + public final List searchAfter() { return this.searchAfter; } @@ -407,8 +408,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(); @@ -578,7 +579,7 @@ public static class Builder extends ObjectBuilderBase implements ObjectBuilder searchAfter; + private List searchAfter; @Nullable private Integer size; @@ -716,7 +717,7 @@ public final Builder postFilter(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; } @@ -726,7 +727,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; } @@ -1092,7 +1093,7 @@ protected static void setupMultisearchBodyDeserializer(ObjectDeserializer implements PlainJsonSerializable { @Nullable private final Long version; - private final List sort; + private final List sort; @Nullable private final JsonpSerializer tDocumentSerializer; @@ -266,7 +267,7 @@ public final Long version() { /** * API name: {@code sort} */ - public final List sort() { + public final List sort() { return this.sort; } @@ -404,8 +405,8 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { if (ApiTypeHelper.isDefined(this.sort)) { generator.writeKey("sort"); generator.writeStartArray(); - for (String item0 : this.sort) { - generator.write(item0); + for (FieldValue item0 : this.sort) { + item0.serialize(generator, mapper); } generator.writeEnd(); @@ -474,7 +475,7 @@ public static class Builder extends ObjectBuilderBase implements Obje private Long version; @Nullable - private List sort; + private List sort; @Nullable private JsonpSerializer tDocumentSerializer; @@ -703,7 +704,7 @@ public final Builder version(@Nullable Long value) { *

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

* Adds one or more values to sort. */ - public final Builder sort(String value, String... values) { + public final Builder sort(FieldValue value, FieldValue... values) { this.sort = _listAdd(this.sort, value, values); return this; } @@ -778,7 +779,7 @@ protected static void setupHitDeserializer( op.add(Builder::seqNo, JsonpDeserializer.longDeserializer(), "_seq_no"); op.add(Builder::primaryTerm, JsonpDeserializer.longDeserializer(), "_primary_term"); op.add(Builder::version, JsonpDeserializer.longDeserializer(), "_version"); - op.add(Builder::sort, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringOrNullDeserializer()), "sort"); + op.add(Builder::sort, JsonpDeserializer.arrayDeserializer(FieldValue._DESERIALIZER), "sort"); }