From c193528d98acaf38fd95f6e763a55c6d0603c8e7 Mon Sep 17 00:00:00 2001 From: Steve Gordon Date: Tue, 13 Dec 2022 14:20:11 +0000 Subject: [PATCH 1/2] Fix code-generated field sort serialization logic --- .../_Generated/Types/SortOptions.g.cs | 4 +-- .../Search/Search/BasicSortUsageTests.cs | 29 +++++++++++++++++++ 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/SortOptions.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/SortOptions.g.cs index 963a246e5e2..b75cde29fff 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/SortOptions.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/SortOptions.g.cs @@ -162,7 +162,7 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o } writer.WriteStartObject(); - writer.WritePropertyName(ContainedVariantName); + writer.WritePropertyName(fieldName); if (Variant is not null) { JsonSerializer.Serialize(writer, Variant, Variant.GetType(), options); @@ -279,7 +279,7 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o } writer.WriteStartObject(); - writer.WritePropertyName(ContainedVariantName); + writer.WritePropertyName(fieldName); if (Variant is not null) { JsonSerializer.Serialize(writer, Variant, Variant.GetType(), options); diff --git a/tests/Tests/Search/Search/BasicSortUsageTests.cs b/tests/Tests/Search/Search/BasicSortUsageTests.cs index 700c97f952e..8670e91cac1 100644 --- a/tests/Tests/Search/Search/BasicSortUsageTests.cs +++ b/tests/Tests/Search/Search/BasicSortUsageTests.cs @@ -3,6 +3,7 @@ // See the LICENSE file in the project root for more information. using System; +using System.Collections.Generic; using Tests.Core.ManagedElasticsearch.Clusters; using Tests.Domain; using Tests.Framework.EndpointTests.TestState; @@ -29,6 +30,34 @@ public BasicSortUsageTests(ReadOnlyCluster cluster, EndpointUsage usage) : base( }; } +public class FieldSortWithOrderUsageTests : SearchUsageTestBase +{ + public FieldSortWithOrderUsageTests(ReadOnlyCluster cluster, EndpointUsage usage) : base(cluster, usage) { } + + protected override object ExpectJson => + new + { + sort = new Dictionary + { + { + "startedOn", new + { + order = "desc" + } + } + } + }; + + protected override Action> Fluent => s => s + .Sort(s => s.Field(f => f.StartedOn, fldsrt => fldsrt.Order(SortOrder.Desc))); + + protected override SearchRequest Initializer => + new() + { + Sort = new[] { SortOptions.Field(Infer.Field(f => f.StartedOn), new FieldSort { Order = SortOrder.Desc }) } + }; +} + public class BasicScoreSortUsageTests : SearchUsageTestBase { public BasicScoreSortUsageTests(ReadOnlyCluster cluster, EndpointUsage usage) : base(cluster, usage) { } From 70bab29e360655b071a5000f31f7883d924c2925 Mon Sep 17 00:00:00 2001 From: Steve Gordon Date: Tue, 13 Dec 2022 14:29:33 +0000 Subject: [PATCH 2/2] Update ES version for tests --- .github/workflows/integration-jobs.yml | 2 +- tests/Tests.Configuration/tests.default.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/integration-jobs.yml b/.github/workflows/integration-jobs.yml index e862ff4c224..a48076529a2 100644 --- a/.github/workflows/integration-jobs.yml +++ b/.github/workflows/integration-jobs.yml @@ -26,7 +26,7 @@ jobs: '8.2.3', '8.3.3', '8.4.3', - "8.5.2", + "8.5.3", '8.6.0-SNAPSHOT', 'latest-8' ] diff --git a/tests/Tests.Configuration/tests.default.yaml b/tests/Tests.Configuration/tests.default.yaml index c28b1f5cc84..625ff159ab8 100644 --- a/tests/Tests.Configuration/tests.default.yaml +++ b/tests/Tests.Configuration/tests.default.yaml @@ -8,7 +8,7 @@ mode: u # the elasticsearch version that should be started # Can be a snapshot version of sonatype or "latest" to get the latest snapshot of sonatype -elasticsearch_version: 8.5.2 +elasticsearch_version: 8.5.3 # cluster filter allows you to only run the integration tests of a particular cluster (cluster suffix not needed) # cluster_filter: # whether we want to forcefully reseed on the node, if you are starting the tests with a node already running