Skip to content

[8.19] Set typed_keys to true by default (#8609) #8610

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
Jun 23, 2025
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
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ public partial class GetAsyncSearchRequest
{
// Any request may contain aggregations so we force `typed_keys` in order to successfully
// deserialize them.
internal override void BeforeRequest() => TypedKeys = true;
internal override void BeforeRequest() => TypedKeys ??= true;
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ namespace Elastic.Clients.Elasticsearch.AsyncSearch;

public partial class SubmitAsyncSearchRequest
{
// Any request may contain aggregations so we force typed_keys in order to successfully deserialize them.
internal override void BeforeRequest() => TypedKeys = true;
// Any request may contain aggregations so we force `typed_keys` in order to successfully
// // deserialize them.
internal override void BeforeRequest() => TypedKeys ??= true;
}

public readonly partial struct SubmitAsyncSearchRequestDescriptor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,15 @@ public partial class MultiSearchResponse<TDocument>

public partial class MultiSearchRequest : IStreamSerializable
{
internal override void BeforeRequest() => TypedKeys = true;
// Any request may contain aggregations so we force `typed_keys` in order to successfully
// deserialize them.
internal override void BeforeRequest()
{
if (Searches.Any(x => x.Body.Aggregations is { Count: > 0 } || x.Body.Suggest is { Suggesters: { Count: > 0 } }))
{
TypedKeys ??= true;
}
}

void IStreamSerializable.Serialize(Stream stream, IElasticsearchClientSettings settings, SerializationFormatting formatting)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public partial class MultiSearchTemplateResponse<TDocument>

public partial class MultiSearchTemplateRequest : IStreamSerializable
{
internal override void BeforeRequest() => TypedKeys = true;
internal override void BeforeRequest() => TypedKeys ??= true;

void IStreamSerializable.Serialize(Stream stream, IElasticsearchClientSettings settings, SerializationFormatting formatting)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information.

namespace Elastic.Clients.Elasticsearch.Rollup;

public partial class RollupSearchRequest
{
// Any request may contain aggregations so we force `typed_keys` in order to successfully
// deserialize them.
internal override void BeforeRequest() => TypedKeys ??= true;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information.

namespace Elastic.Clients.Elasticsearch.SearchApplication;

public partial class SearchApplicationSearchRequest
{
// Any request may contain aggregations so we force `typed_keys` in order to successfully
// deserialize them.
internal override void BeforeRequest() => TypedKeys ??= true;
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ public partial class SearchRequest
{
internal override void BeforeRequest()
{
if (Aggregations is not null || Suggest is not null)
if (Aggregations is { Count: > 0 } || Suggest is { Suggesters: { Count: > 0 } })
{
TypedKeys = true;
TypedKeys ??= true;
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information.

namespace Elastic.Clients.Elasticsearch;

public partial class SearchTemplateRequest
{
// Any request may contain aggregations so we force `typed_keys` in order to successfully
// deserialize them.
internal override void BeforeRequest() => TypedKeys ??= true;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information.

namespace Elastic.Clients.Elasticsearch.Security;

public partial class QueryApiKeysRequest
{
// Any request may contain aggregations so we force `typed_keys` in order to successfully
// deserialize them.
internal override void BeforeRequest()
{
if (Aggregations is { Count: > 0 })
{
TypedKeys ??= true;
}
}
}