Skip to content

Commit 2c4c8e1

Browse files
stevejgordongithub-actions[bot]
authored andcommitted
Fix field sort serialization (#7094)
* Fix code-generated field sort serialization logic * Update ES version for tests
1 parent 3f3079f commit 2c4c8e1

File tree

4 files changed

+33
-4
lines changed

4 files changed

+33
-4
lines changed

.github/workflows/integration-jobs.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
'8.2.3',
2727
'8.3.3',
2828
'8.4.3',
29-
"8.5.2",
29+
"8.5.3",
3030
'8.6.0-SNAPSHOT',
3131
'latest-8'
3232
]

src/Elastic.Clients.Elasticsearch/_Generated/Types/SortOptions.g.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o
162162
}
163163

164164
writer.WriteStartObject();
165-
writer.WritePropertyName(ContainedVariantName);
165+
writer.WritePropertyName(fieldName);
166166
if (Variant is not null)
167167
{
168168
JsonSerializer.Serialize(writer, Variant, Variant.GetType(), options);
@@ -279,7 +279,7 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o
279279
}
280280

281281
writer.WriteStartObject();
282-
writer.WritePropertyName(ContainedVariantName);
282+
writer.WritePropertyName(fieldName);
283283
if (Variant is not null)
284284
{
285285
JsonSerializer.Serialize(writer, Variant, Variant.GetType(), options);

tests/Tests.Configuration/tests.default.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
mode: u
99
# the elasticsearch version that should be started
1010
# Can be a snapshot version of sonatype or "latest" to get the latest snapshot of sonatype
11-
elasticsearch_version: 8.5.2
11+
elasticsearch_version: 8.5.3
1212
# cluster filter allows you to only run the integration tests of a particular cluster (cluster suffix not needed)
1313
# cluster_filter:
1414
# whether we want to forcefully reseed on the node, if you are starting the tests with a node already running

tests/Tests/Search/Search/BasicSortUsageTests.cs

+29
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// See the LICENSE file in the project root for more information.
44

55
using System;
6+
using System.Collections.Generic;
67
using Tests.Core.ManagedElasticsearch.Clusters;
78
using Tests.Domain;
89
using Tests.Framework.EndpointTests.TestState;
@@ -29,6 +30,34 @@ public BasicSortUsageTests(ReadOnlyCluster cluster, EndpointUsage usage) : base(
2930
};
3031
}
3132

33+
public class FieldSortWithOrderUsageTests : SearchUsageTestBase
34+
{
35+
public FieldSortWithOrderUsageTests(ReadOnlyCluster cluster, EndpointUsage usage) : base(cluster, usage) { }
36+
37+
protected override object ExpectJson =>
38+
new
39+
{
40+
sort = new Dictionary<string, object>
41+
{
42+
{
43+
"startedOn", new
44+
{
45+
order = "desc"
46+
}
47+
}
48+
}
49+
};
50+
51+
protected override Action<SearchRequestDescriptor<Project>> Fluent => s => s
52+
.Sort(s => s.Field(f => f.StartedOn, fldsrt => fldsrt.Order(SortOrder.Desc)));
53+
54+
protected override SearchRequest<Project> Initializer =>
55+
new()
56+
{
57+
Sort = new[] { SortOptions.Field(Infer.Field<Project>(f => f.StartedOn), new FieldSort { Order = SortOrder.Desc }) }
58+
};
59+
}
60+
3261
public class BasicScoreSortUsageTests : SearchUsageTestBase
3362
{
3463
public BasicScoreSortUsageTests(ReadOnlyCluster cluster, EndpointUsage usage) : base(cluster, usage) { }

0 commit comments

Comments
 (0)