diff --git a/CHANGELOG.md b/CHANGELOG.md index 4d0512de31..2d3936e08d 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` ([#1225](https://github.com/opensearch-project/opensearch-java/pull/1225)) +- Changed type of `MultisearchBody`'s `searchAfter` field from `List` to `List` ([#1225](https://github.com/opensearch-project/opensearch-java/pull/1225)) ### 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"); } diff --git a/java-client/src/test/java11/org/opensearch/client/opensearch/integTest/AbstractMultiSearchRequestIT.java b/java-client/src/test/java11/org/opensearch/client/opensearch/integTest/AbstractMultiSearchRequestIT.java index de43d9fe05..0d35a11f7e 100644 --- a/java-client/src/test/java11/org/opensearch/client/opensearch/integTest/AbstractMultiSearchRequestIT.java +++ b/java-client/src/test/java11/org/opensearch/client/opensearch/integTest/AbstractMultiSearchRequestIT.java @@ -179,7 +179,7 @@ public void shouldReturnMultiSearchesSearchAfter() throws Exception { assertEquals(1, response.responses().size()); assertEquals(3, response.responses().get(0).result().hits().hits().size()); - List sorts = response.responses().get(0).result().hits().hits().get(1).sort(); + List sorts = response.responses().get(0).result().hits().hits().get(1).sort(); RequestItem sortedAfterItemsQuery = createMSearchSortedFuzzyRequest(b -> b.searchAfter(sorts)); MsearchResponse response2 = sendMSearchRequest(index, List.of(sortedAfterItemsQuery));