Skip to content

[Backport 8.2] Fix field sort serialization #7097

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/integration-jobs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion tests/Tests.Configuration/tests.default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
29 changes: 29 additions & 0 deletions tests/Tests/Search/Search/BasicSortUsageTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<string, object>
{
{
"startedOn", new
{
order = "desc"
}
}
}
};

protected override Action<SearchRequestDescriptor<Project>> Fluent => s => s
.Sort(s => s.Field(f => f.StartedOn, fldsrt => fldsrt.Order(SortOrder.Desc)));

protected override SearchRequest<Project> Initializer =>
new()
{
Sort = new[] { SortOptions.Field(Infer.Field<Project>(f => f.StartedOn), new FieldSort { Order = SortOrder.Desc }) }
};
}

public class BasicScoreSortUsageTests : SearchUsageTestBase
{
public BasicScoreSortUsageTests(ReadOnlyCluster cluster, EndpointUsage usage) : base(cluster, usage) { }
Expand Down