diff --git a/src/Elastic.Clients.Elasticsearch/Common/Aggregations/Aggregate.cs b/src/Elastic.Clients.Elasticsearch/Common/Aggregations/IAggregate.cs similarity index 71% rename from src/Elastic.Clients.Elasticsearch/Common/Aggregations/Aggregate.cs rename to src/Elastic.Clients.Elasticsearch/Common/Aggregations/IAggregate.cs index ffcd45a097a..8bd38d481ee 100644 --- a/src/Elastic.Clients.Elasticsearch/Common/Aggregations/Aggregate.cs +++ b/src/Elastic.Clients.Elasticsearch/Common/Aggregations/IAggregate.cs @@ -5,12 +5,3 @@ namespace Elastic.Clients.Elasticsearch.Aggregations; public interface IAggregate { } - -/// -/// Base class for all aggregates. -/// -public abstract class Aggregate : IAggregate -{ -} - - diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/GetSnapshotRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/GetSnapshotRequest.g.cs index c2ffa74c199..354099398d2 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/GetSnapshotRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/GetSnapshotRequest.g.cs @@ -39,6 +39,9 @@ public sealed class GetSnapshotRequestParameters : RequestParameters Q("index_details"); set => Q("index_details", value); } + [JsonIgnore] + public bool? IndexNames { get => Q("index_names"); set => Q("index_names", value); } + [JsonIgnore] public bool? IncludeRepository { get => Q("include_repository"); set => Q("include_repository", value); } @@ -85,6 +88,9 @@ public GetSnapshotRequest(Elastic.Clients.Elasticsearch.Name repository, Elastic [JsonIgnore] public bool? IndexDetails { get => Q("index_details"); set => Q("index_details", value); } + [JsonIgnore] + public bool? IndexNames { get => Q("index_names"); set => Q("index_names", value); } + [JsonIgnore] public bool? IncludeRepository { get => Q("include_repository"); set => Q("include_repository", value); } @@ -129,6 +135,7 @@ internal GetSnapshotRequestDescriptor() public GetSnapshotRequestDescriptor IgnoreUnavailable(bool? ignoreUnavailable = true) => Qs("ignore_unavailable", ignoreUnavailable); public GetSnapshotRequestDescriptor IncludeRepository(bool? includeRepository = true) => Qs("include_repository", includeRepository); public GetSnapshotRequestDescriptor IndexDetails(bool? indexDetails = true) => Qs("index_details", indexDetails); + public GetSnapshotRequestDescriptor IndexNames(bool? indexNames = true) => Qs("index_names", indexNames); public GetSnapshotRequestDescriptor MasterTimeout(Elastic.Clients.Elasticsearch.Duration? masterTimeout) => Qs("master_timeout", masterTimeout); public GetSnapshotRequestDescriptor Offset(int? offset) => Qs("offset", offset); public GetSnapshotRequestDescriptor Order(Elastic.Clients.Elasticsearch.SortOrder? order) => Qs("order", order); diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/AdjacencyMatrixAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/AdjacencyMatrixAggregate.g.cs index 0daed13d494..e796df4cbb1 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/AdjacencyMatrixAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/AdjacencyMatrixAggregate.g.cs @@ -24,7 +24,7 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.Aggregations { - public sealed partial class AdjacencyMatrixAggregate : Aggregate + public sealed partial class AdjacencyMatrixAggregate : IAggregate { [JsonInclude] [JsonPropertyName("buckets")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/AutoDateHistogramAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/AutoDateHistogramAggregate.g.cs index c7a660c949f..d9df4ae316f 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/AutoDateHistogramAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/AutoDateHistogramAggregate.g.cs @@ -24,7 +24,7 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.Aggregations { - public sealed partial class AutoDateHistogramAggregate : Aggregate + public sealed partial class AutoDateHistogramAggregate : IAggregate { [JsonInclude] [JsonPropertyName("buckets")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/AvgAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/AvgAggregate.g.cs index 3d137641e3a..41bc6059c53 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/AvgAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/AvgAggregate.g.cs @@ -24,7 +24,7 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.Aggregations { - public sealed partial class AvgAggregate : Aggregate + public sealed partial class AvgAggregate : IAggregate { [JsonInclude] [JsonPropertyName("meta")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/BoxPlotAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/BoxPlotAggregate.g.cs index 6390e540c74..981f5367507 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/BoxPlotAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/BoxPlotAggregate.g.cs @@ -24,7 +24,7 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.Aggregations { - public sealed partial class BoxPlotAggregate : Aggregate + public sealed partial class BoxPlotAggregate : IAggregate { [JsonInclude] [JsonPropertyName("lower")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/CardinalityAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/CardinalityAggregate.g.cs index 04e843e9997..be25ff8d83d 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/CardinalityAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/CardinalityAggregate.g.cs @@ -24,7 +24,7 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.Aggregations { - public sealed partial class CardinalityAggregate : Aggregate + public sealed partial class CardinalityAggregate : IAggregate { [JsonInclude] [JsonPropertyName("meta")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/ChildrenAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/ChildrenAggregate.g.cs index 26aa561bc91..8ba5c1d5e48 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/ChildrenAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/ChildrenAggregate.g.cs @@ -24,11 +24,12 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.Aggregations { - public sealed partial class ChildrenAggregate : Aggregate + [JsonConverter(typeof(ChildrenAggregateConverter))] + public sealed partial class ChildrenAggregate : AggregateDictionary, IAggregate { - [JsonInclude] - [JsonPropertyName("aggregations")] - public Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionary Aggregations { get; init; } + public ChildrenAggregate(IReadOnlyDictionary backingDictionary) : base(backingDictionary) + { + } [JsonInclude] [JsonPropertyName("doc_count")] @@ -38,4 +39,49 @@ public sealed partial class ChildrenAggregate : Aggregate [JsonPropertyName("meta")] public Dictionary? Meta { get; init; } } + + internal sealed class ChildrenAggregateConverter : JsonConverter + { + public override ChildrenAggregate? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + if (reader.TokenType != JsonTokenType.StartObject) + throw new JsonException($"Expected {JsonTokenType.StartObject} but read {reader.TokenType}."); + var subAggs = new Dictionary(); // TODO - Optimise this and only create if we need it. + long docCount = default; + Dictionary? meta = default; + while (reader.Read()) + { + if (reader.TokenType == JsonTokenType.EndObject) + break; + if (reader.TokenType != JsonTokenType.PropertyName) + throw new JsonException($"Expected {JsonTokenType.PropertyName} but read {reader.TokenType}."); + var name = reader.GetString(); // TODO: Future optimisation, get raw bytes span and parse based on those + reader.Read(); + if (name.Equals("doc_count", StringComparison.Ordinal)) + { + docCount = JsonSerializer.Deserialize(ref reader, options); + continue; + } + + if (name.Equals("meta", StringComparison.Ordinal)) + { + meta = JsonSerializer.Deserialize?>(ref reader, options); + continue; + } + + if (name.Contains("#")) + { + AggregateDictionaryConverter.ReadAggregate(ref reader, options, subAggs, name); + continue; + } + + throw new JsonException("Unknown property read from JSON."); + } + + return new ChildrenAggregate(subAggs) + { DocCount = docCount, Meta = meta }; + } + + public override void Write(Utf8JsonWriter writer, ChildrenAggregate value, JsonSerializerOptions options) => throw new NotImplementedException(); + } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/CompositeAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/CompositeAggregate.g.cs index cc63d7dda66..198effa27fe 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/CompositeAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/CompositeAggregate.g.cs @@ -24,7 +24,7 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.Aggregations { - public sealed partial class CompositeAggregate : Aggregate + public sealed partial class CompositeAggregate : IAggregate { [JsonInclude] [JsonPropertyName("after_key")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/CumulativeCardinalityAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/CumulativeCardinalityAggregate.g.cs index c519e39708e..34f2ab4e1d7 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/CumulativeCardinalityAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/CumulativeCardinalityAggregate.g.cs @@ -24,7 +24,7 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.Aggregations { - public sealed partial class CumulativeCardinalityAggregate : Aggregate + public sealed partial class CumulativeCardinalityAggregate : IAggregate { [JsonInclude] [JsonPropertyName("meta")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/DateHistogramAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/DateHistogramAggregate.g.cs index e5fc1e720fb..c9cf5eca82a 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/DateHistogramAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/DateHistogramAggregate.g.cs @@ -24,7 +24,7 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.Aggregations { - public sealed partial class DateHistogramAggregate : Aggregate + public sealed partial class DateHistogramAggregate : IAggregate { [JsonInclude] [JsonPropertyName("buckets")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/DateRangeAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/DateRangeAggregate.g.cs index 446042aea0e..f7dcced0a04 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/DateRangeAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/DateRangeAggregate.g.cs @@ -24,7 +24,7 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.Aggregations { - public sealed partial class DateRangeAggregate : Aggregate + public sealed partial class DateRangeAggregate : IAggregate { [JsonInclude] [JsonPropertyName("buckets")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/DerivativeAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/DerivativeAggregate.g.cs index 0dd4a0b4646..9f8d41d5f34 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/DerivativeAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/DerivativeAggregate.g.cs @@ -24,7 +24,7 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.Aggregations { - public sealed partial class DerivativeAggregate : Aggregate + public sealed partial class DerivativeAggregate : IAggregate { [JsonInclude] [JsonPropertyName("meta")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/DoubleTermsAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/DoubleTermsAggregate.g.cs index 39ce3bc1c18..3f52b2650f0 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/DoubleTermsAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/DoubleTermsAggregate.g.cs @@ -24,7 +24,7 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.Aggregations { - public sealed partial class DoubleTermsAggregate : Aggregate + public sealed partial class DoubleTermsAggregate : IAggregate { [JsonInclude] [JsonPropertyName("buckets")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/ExtendedStatsAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/ExtendedStatsAggregate.g.cs index 5273f7a7154..070b6800714 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/ExtendedStatsAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/ExtendedStatsAggregate.g.cs @@ -24,7 +24,7 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.Aggregations { - public sealed partial class ExtendedStatsAggregate : Aggregate + public sealed partial class ExtendedStatsAggregate : IAggregate { [JsonInclude] [JsonPropertyName("avg")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/ExtendedStatsBucketAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/ExtendedStatsBucketAggregate.g.cs index 81aa3dfaa98..418bf7cefca 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/ExtendedStatsBucketAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/ExtendedStatsBucketAggregate.g.cs @@ -24,7 +24,7 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.Aggregations { - public sealed partial class ExtendedStatsBucketAggregate : Aggregate + public sealed partial class ExtendedStatsBucketAggregate : IAggregate { [JsonInclude] [JsonPropertyName("avg")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/FilterAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/FilterAggregate.g.cs index 18d3dca48fe..9622b66d717 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/FilterAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/FilterAggregate.g.cs @@ -24,11 +24,12 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.Aggregations { - public sealed partial class FilterAggregate : Aggregate + [JsonConverter(typeof(FilterAggregateConverter))] + public sealed partial class FilterAggregate : AggregateDictionary, IAggregate { - [JsonInclude] - [JsonPropertyName("aggregations")] - public Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionary Aggregations { get; init; } + public FilterAggregate(IReadOnlyDictionary backingDictionary) : base(backingDictionary) + { + } [JsonInclude] [JsonPropertyName("doc_count")] @@ -38,4 +39,49 @@ public sealed partial class FilterAggregate : Aggregate [JsonPropertyName("meta")] public Dictionary? Meta { get; init; } } + + internal sealed class FilterAggregateConverter : JsonConverter + { + public override FilterAggregate? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + if (reader.TokenType != JsonTokenType.StartObject) + throw new JsonException($"Expected {JsonTokenType.StartObject} but read {reader.TokenType}."); + var subAggs = new Dictionary(); // TODO - Optimise this and only create if we need it. + long docCount = default; + Dictionary? meta = default; + while (reader.Read()) + { + if (reader.TokenType == JsonTokenType.EndObject) + break; + if (reader.TokenType != JsonTokenType.PropertyName) + throw new JsonException($"Expected {JsonTokenType.PropertyName} but read {reader.TokenType}."); + var name = reader.GetString(); // TODO: Future optimisation, get raw bytes span and parse based on those + reader.Read(); + if (name.Equals("doc_count", StringComparison.Ordinal)) + { + docCount = JsonSerializer.Deserialize(ref reader, options); + continue; + } + + if (name.Equals("meta", StringComparison.Ordinal)) + { + meta = JsonSerializer.Deserialize?>(ref reader, options); + continue; + } + + if (name.Contains("#")) + { + AggregateDictionaryConverter.ReadAggregate(ref reader, options, subAggs, name); + continue; + } + + throw new JsonException("Unknown property read from JSON."); + } + + return new FilterAggregate(subAggs) + { DocCount = docCount, Meta = meta }; + } + + public override void Write(Utf8JsonWriter writer, FilterAggregate value, JsonSerializerOptions options) => throw new NotImplementedException(); + } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/FiltersAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/FiltersAggregate.g.cs index 072d03b0e94..858b77b0f0a 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/FiltersAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/FiltersAggregate.g.cs @@ -24,7 +24,7 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.Aggregations { - public sealed partial class FiltersAggregate : Aggregate + public sealed partial class FiltersAggregate : IAggregate { [JsonInclude] [JsonPropertyName("buckets")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/GlobalAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/GlobalAggregate.g.cs index 3e9cbc29a2f..a3ed501912f 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/GlobalAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/GlobalAggregate.g.cs @@ -24,11 +24,12 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.Aggregations { - public sealed partial class GlobalAggregate : Aggregate + [JsonConverter(typeof(GlobalAggregateConverter))] + public sealed partial class GlobalAggregate : AggregateDictionary, IAggregate { - [JsonInclude] - [JsonPropertyName("aggregations")] - public Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionary Aggregations { get; init; } + public GlobalAggregate(IReadOnlyDictionary backingDictionary) : base(backingDictionary) + { + } [JsonInclude] [JsonPropertyName("doc_count")] @@ -38,4 +39,49 @@ public sealed partial class GlobalAggregate : Aggregate [JsonPropertyName("meta")] public Dictionary? Meta { get; init; } } + + internal sealed class GlobalAggregateConverter : JsonConverter + { + public override GlobalAggregate? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + if (reader.TokenType != JsonTokenType.StartObject) + throw new JsonException($"Expected {JsonTokenType.StartObject} but read {reader.TokenType}."); + var subAggs = new Dictionary(); // TODO - Optimise this and only create if we need it. + long docCount = default; + Dictionary? meta = default; + while (reader.Read()) + { + if (reader.TokenType == JsonTokenType.EndObject) + break; + if (reader.TokenType != JsonTokenType.PropertyName) + throw new JsonException($"Expected {JsonTokenType.PropertyName} but read {reader.TokenType}."); + var name = reader.GetString(); // TODO: Future optimisation, get raw bytes span and parse based on those + reader.Read(); + if (name.Equals("doc_count", StringComparison.Ordinal)) + { + docCount = JsonSerializer.Deserialize(ref reader, options); + continue; + } + + if (name.Equals("meta", StringComparison.Ordinal)) + { + meta = JsonSerializer.Deserialize?>(ref reader, options); + continue; + } + + if (name.Contains("#")) + { + AggregateDictionaryConverter.ReadAggregate(ref reader, options, subAggs, name); + continue; + } + + throw new JsonException("Unknown property read from JSON."); + } + + return new GlobalAggregate(subAggs) + { DocCount = docCount, Meta = meta }; + } + + public override void Write(Utf8JsonWriter writer, GlobalAggregate value, JsonSerializerOptions options) => throw new NotImplementedException(); + } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/HistogramAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/HistogramAggregate.g.cs index 6ff6f7fa876..33435a1d204 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/HistogramAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/HistogramAggregate.g.cs @@ -24,7 +24,7 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.Aggregations { - public sealed partial class HistogramAggregate : Aggregate + public sealed partial class HistogramAggregate : IAggregate { [JsonInclude] [JsonPropertyName("buckets")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/InferenceAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/InferenceAggregate.g.cs index 059f2984e8d..317b9c2d830 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/InferenceAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/InferenceAggregate.g.cs @@ -24,7 +24,7 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.Aggregations { - public sealed partial class InferenceAggregate : Aggregate + public sealed partial class InferenceAggregate : IAggregate { [JsonInclude] [JsonPropertyName("data")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/IpRangeAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/IpRangeAggregate.g.cs index 97372e4127c..a34dd20cff2 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/IpRangeAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/IpRangeAggregate.g.cs @@ -24,7 +24,7 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.Aggregations { - public sealed partial class IpRangeAggregate : Aggregate + public sealed partial class IpRangeAggregate : IAggregate { [JsonInclude] [JsonPropertyName("buckets")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/LongTermsAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/LongTermsAggregate.g.cs index 005cea93ecb..eca5789faa0 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/LongTermsAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/LongTermsAggregate.g.cs @@ -24,7 +24,7 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.Aggregations { - public sealed partial class LongTermsAggregate : Aggregate + public sealed partial class LongTermsAggregate : IAggregate { [JsonInclude] [JsonPropertyName("buckets")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/MatrixStatsAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/MatrixStatsAggregate.g.cs index 44b932804cf..9a7bf4d5374 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/MatrixStatsAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/MatrixStatsAggregate.g.cs @@ -24,7 +24,7 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.Aggregations { - public sealed partial class MatrixStatsAggregate : Aggregate + public sealed partial class MatrixStatsAggregate : IAggregate { [JsonInclude] [JsonPropertyName("doc_count")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/MaxAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/MaxAggregate.g.cs index 6b4cb14646f..18de69c6e2f 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/MaxAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/MaxAggregate.g.cs @@ -24,7 +24,7 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.Aggregations { - public sealed partial class MaxAggregate : Aggregate + public sealed partial class MaxAggregate : IAggregate { [JsonInclude] [JsonPropertyName("meta")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/MedianAbsoluteDeviationAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/MedianAbsoluteDeviationAggregate.g.cs index 24834036a02..e4bc1af73a9 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/MedianAbsoluteDeviationAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/MedianAbsoluteDeviationAggregate.g.cs @@ -24,7 +24,7 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.Aggregations { - public sealed partial class MedianAbsoluteDeviationAggregate : Aggregate + public sealed partial class MedianAbsoluteDeviationAggregate : IAggregate { [JsonInclude] [JsonPropertyName("meta")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/MinAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/MinAggregate.g.cs index 5c1b2ac2677..d03d1b26559 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/MinAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/MinAggregate.g.cs @@ -24,7 +24,7 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.Aggregations { - public sealed partial class MinAggregate : Aggregate + public sealed partial class MinAggregate : IAggregate { [JsonInclude] [JsonPropertyName("meta")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/MissingAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/MissingAggregate.g.cs index 521955a5ce3..b475f08255f 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/MissingAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/MissingAggregate.g.cs @@ -24,11 +24,12 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.Aggregations { - public sealed partial class MissingAggregate : Aggregate + [JsonConverter(typeof(MissingAggregateConverter))] + public sealed partial class MissingAggregate : AggregateDictionary, IAggregate { - [JsonInclude] - [JsonPropertyName("aggregations")] - public Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionary Aggregations { get; init; } + public MissingAggregate(IReadOnlyDictionary backingDictionary) : base(backingDictionary) + { + } [JsonInclude] [JsonPropertyName("doc_count")] @@ -38,4 +39,49 @@ public sealed partial class MissingAggregate : Aggregate [JsonPropertyName("meta")] public Dictionary? Meta { get; init; } } + + internal sealed class MissingAggregateConverter : JsonConverter + { + public override MissingAggregate? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + if (reader.TokenType != JsonTokenType.StartObject) + throw new JsonException($"Expected {JsonTokenType.StartObject} but read {reader.TokenType}."); + var subAggs = new Dictionary(); // TODO - Optimise this and only create if we need it. + long docCount = default; + Dictionary? meta = default; + while (reader.Read()) + { + if (reader.TokenType == JsonTokenType.EndObject) + break; + if (reader.TokenType != JsonTokenType.PropertyName) + throw new JsonException($"Expected {JsonTokenType.PropertyName} but read {reader.TokenType}."); + var name = reader.GetString(); // TODO: Future optimisation, get raw bytes span and parse based on those + reader.Read(); + if (name.Equals("doc_count", StringComparison.Ordinal)) + { + docCount = JsonSerializer.Deserialize(ref reader, options); + continue; + } + + if (name.Equals("meta", StringComparison.Ordinal)) + { + meta = JsonSerializer.Deserialize?>(ref reader, options); + continue; + } + + if (name.Contains("#")) + { + AggregateDictionaryConverter.ReadAggregate(ref reader, options, subAggs, name); + continue; + } + + throw new JsonException("Unknown property read from JSON."); + } + + return new MissingAggregate(subAggs) + { DocCount = docCount, Meta = meta }; + } + + public override void Write(Utf8JsonWriter writer, MissingAggregate value, JsonSerializerOptions options) => throw new NotImplementedException(); + } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/MultiTermsAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/MultiTermsAggregate.g.cs index 000510ff13e..166021709ff 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/MultiTermsAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/MultiTermsAggregate.g.cs @@ -24,7 +24,7 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.Aggregations { - public sealed partial class MultiTermsAggregate : Aggregate + public sealed partial class MultiTermsAggregate : IAggregate { [JsonInclude] [JsonPropertyName("buckets")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/NestedAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/NestedAggregate.g.cs index 2c72fa4d2e4..201c0afb5d2 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/NestedAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/NestedAggregate.g.cs @@ -24,11 +24,12 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.Aggregations { - public sealed partial class NestedAggregate : Aggregate + [JsonConverter(typeof(NestedAggregateConverter))] + public sealed partial class NestedAggregate : AggregateDictionary, IAggregate { - [JsonInclude] - [JsonPropertyName("aggregations")] - public Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionary Aggregations { get; init; } + public NestedAggregate(IReadOnlyDictionary backingDictionary) : base(backingDictionary) + { + } [JsonInclude] [JsonPropertyName("doc_count")] @@ -38,4 +39,49 @@ public sealed partial class NestedAggregate : Aggregate [JsonPropertyName("meta")] public Dictionary? Meta { get; init; } } + + internal sealed class NestedAggregateConverter : JsonConverter + { + public override NestedAggregate? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + if (reader.TokenType != JsonTokenType.StartObject) + throw new JsonException($"Expected {JsonTokenType.StartObject} but read {reader.TokenType}."); + var subAggs = new Dictionary(); // TODO - Optimise this and only create if we need it. + long docCount = default; + Dictionary? meta = default; + while (reader.Read()) + { + if (reader.TokenType == JsonTokenType.EndObject) + break; + if (reader.TokenType != JsonTokenType.PropertyName) + throw new JsonException($"Expected {JsonTokenType.PropertyName} but read {reader.TokenType}."); + var name = reader.GetString(); // TODO: Future optimisation, get raw bytes span and parse based on those + reader.Read(); + if (name.Equals("doc_count", StringComparison.Ordinal)) + { + docCount = JsonSerializer.Deserialize(ref reader, options); + continue; + } + + if (name.Equals("meta", StringComparison.Ordinal)) + { + meta = JsonSerializer.Deserialize?>(ref reader, options); + continue; + } + + if (name.Contains("#")) + { + AggregateDictionaryConverter.ReadAggregate(ref reader, options, subAggs, name); + continue; + } + + throw new JsonException("Unknown property read from JSON."); + } + + return new NestedAggregate(subAggs) + { DocCount = docCount, Meta = meta }; + } + + public override void Write(Utf8JsonWriter writer, NestedAggregate value, JsonSerializerOptions options) => throw new NotImplementedException(); + } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/ParentAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/ParentAggregate.g.cs index aa8f3e97f23..dea929f0719 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/ParentAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/ParentAggregate.g.cs @@ -24,11 +24,12 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.Aggregations { - public sealed partial class ParentAggregate : Aggregate + [JsonConverter(typeof(ParentAggregateConverter))] + public sealed partial class ParentAggregate : AggregateDictionary, IAggregate { - [JsonInclude] - [JsonPropertyName("aggregations")] - public Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionary Aggregations { get; init; } + public ParentAggregate(IReadOnlyDictionary backingDictionary) : base(backingDictionary) + { + } [JsonInclude] [JsonPropertyName("doc_count")] @@ -38,4 +39,49 @@ public sealed partial class ParentAggregate : Aggregate [JsonPropertyName("meta")] public Dictionary? Meta { get; init; } } + + internal sealed class ParentAggregateConverter : JsonConverter + { + public override ParentAggregate? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + if (reader.TokenType != JsonTokenType.StartObject) + throw new JsonException($"Expected {JsonTokenType.StartObject} but read {reader.TokenType}."); + var subAggs = new Dictionary(); // TODO - Optimise this and only create if we need it. + long docCount = default; + Dictionary? meta = default; + while (reader.Read()) + { + if (reader.TokenType == JsonTokenType.EndObject) + break; + if (reader.TokenType != JsonTokenType.PropertyName) + throw new JsonException($"Expected {JsonTokenType.PropertyName} but read {reader.TokenType}."); + var name = reader.GetString(); // TODO: Future optimisation, get raw bytes span and parse based on those + reader.Read(); + if (name.Equals("doc_count", StringComparison.Ordinal)) + { + docCount = JsonSerializer.Deserialize(ref reader, options); + continue; + } + + if (name.Equals("meta", StringComparison.Ordinal)) + { + meta = JsonSerializer.Deserialize?>(ref reader, options); + continue; + } + + if (name.Contains("#")) + { + AggregateDictionaryConverter.ReadAggregate(ref reader, options, subAggs, name); + continue; + } + + throw new JsonException("Unknown property read from JSON."); + } + + return new ParentAggregate(subAggs) + { DocCount = docCount, Meta = meta }; + } + + public override void Write(Utf8JsonWriter writer, ParentAggregate value, JsonSerializerOptions options) => throw new NotImplementedException(); + } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/PercentilesBucketAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/PercentilesBucketAggregate.g.cs index 90fd244d7b1..9268472267a 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/PercentilesBucketAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/PercentilesBucketAggregate.g.cs @@ -24,7 +24,7 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.Aggregations { - public sealed partial class PercentilesBucketAggregate : Aggregate + public sealed partial class PercentilesBucketAggregate : IAggregate { [JsonInclude] [JsonPropertyName("meta")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/RangeAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/RangeAggregate.g.cs index 2d681597e33..2f1520025d0 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/RangeAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/RangeAggregate.g.cs @@ -24,7 +24,7 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.Aggregations { - public sealed partial class RangeAggregate : Aggregate + public sealed partial class RangeAggregate : IAggregate { [JsonInclude] [JsonPropertyName("buckets")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/RateAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/RateAggregate.g.cs index 41a01a0bee5..6dbd257ce2b 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/RateAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/RateAggregate.g.cs @@ -24,7 +24,7 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.Aggregations { - public sealed partial class RateAggregate : Aggregate + public sealed partial class RateAggregate : IAggregate { [JsonInclude] [JsonPropertyName("meta")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/ReverseNestedAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/ReverseNestedAggregate.g.cs index c7c346663d6..05694c97e45 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/ReverseNestedAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/ReverseNestedAggregate.g.cs @@ -24,11 +24,12 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.Aggregations { - public sealed partial class ReverseNestedAggregate : Aggregate + [JsonConverter(typeof(ReverseNestedAggregateConverter))] + public sealed partial class ReverseNestedAggregate : AggregateDictionary, IAggregate { - [JsonInclude] - [JsonPropertyName("aggregations")] - public Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionary Aggregations { get; init; } + public ReverseNestedAggregate(IReadOnlyDictionary backingDictionary) : base(backingDictionary) + { + } [JsonInclude] [JsonPropertyName("doc_count")] @@ -38,4 +39,49 @@ public sealed partial class ReverseNestedAggregate : Aggregate [JsonPropertyName("meta")] public Dictionary? Meta { get; init; } } + + internal sealed class ReverseNestedAggregateConverter : JsonConverter + { + public override ReverseNestedAggregate? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + if (reader.TokenType != JsonTokenType.StartObject) + throw new JsonException($"Expected {JsonTokenType.StartObject} but read {reader.TokenType}."); + var subAggs = new Dictionary(); // TODO - Optimise this and only create if we need it. + long docCount = default; + Dictionary? meta = default; + while (reader.Read()) + { + if (reader.TokenType == JsonTokenType.EndObject) + break; + if (reader.TokenType != JsonTokenType.PropertyName) + throw new JsonException($"Expected {JsonTokenType.PropertyName} but read {reader.TokenType}."); + var name = reader.GetString(); // TODO: Future optimisation, get raw bytes span and parse based on those + reader.Read(); + if (name.Equals("doc_count", StringComparison.Ordinal)) + { + docCount = JsonSerializer.Deserialize(ref reader, options); + continue; + } + + if (name.Equals("meta", StringComparison.Ordinal)) + { + meta = JsonSerializer.Deserialize?>(ref reader, options); + continue; + } + + if (name.Contains("#")) + { + AggregateDictionaryConverter.ReadAggregate(ref reader, options, subAggs, name); + continue; + } + + throw new JsonException("Unknown property read from JSON."); + } + + return new ReverseNestedAggregate(subAggs) + { DocCount = docCount, Meta = meta }; + } + + public override void Write(Utf8JsonWriter writer, ReverseNestedAggregate value, JsonSerializerOptions options) => throw new NotImplementedException(); + } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/SamplerAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/SamplerAggregate.g.cs index 8d521e9de71..9a6b09429e7 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/SamplerAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/SamplerAggregate.g.cs @@ -24,11 +24,12 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.Aggregations { - public sealed partial class SamplerAggregate : Aggregate + [JsonConverter(typeof(SamplerAggregateConverter))] + public sealed partial class SamplerAggregate : AggregateDictionary, IAggregate { - [JsonInclude] - [JsonPropertyName("aggregations")] - public Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionary Aggregations { get; init; } + public SamplerAggregate(IReadOnlyDictionary backingDictionary) : base(backingDictionary) + { + } [JsonInclude] [JsonPropertyName("doc_count")] @@ -38,4 +39,49 @@ public sealed partial class SamplerAggregate : Aggregate [JsonPropertyName("meta")] public Dictionary? Meta { get; init; } } + + internal sealed class SamplerAggregateConverter : JsonConverter + { + public override SamplerAggregate? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + if (reader.TokenType != JsonTokenType.StartObject) + throw new JsonException($"Expected {JsonTokenType.StartObject} but read {reader.TokenType}."); + var subAggs = new Dictionary(); // TODO - Optimise this and only create if we need it. + long docCount = default; + Dictionary? meta = default; + while (reader.Read()) + { + if (reader.TokenType == JsonTokenType.EndObject) + break; + if (reader.TokenType != JsonTokenType.PropertyName) + throw new JsonException($"Expected {JsonTokenType.PropertyName} but read {reader.TokenType}."); + var name = reader.GetString(); // TODO: Future optimisation, get raw bytes span and parse based on those + reader.Read(); + if (name.Equals("doc_count", StringComparison.Ordinal)) + { + docCount = JsonSerializer.Deserialize(ref reader, options); + continue; + } + + if (name.Equals("meta", StringComparison.Ordinal)) + { + meta = JsonSerializer.Deserialize?>(ref reader, options); + continue; + } + + if (name.Contains("#")) + { + AggregateDictionaryConverter.ReadAggregate(ref reader, options, subAggs, name); + continue; + } + + throw new JsonException("Unknown property read from JSON."); + } + + return new SamplerAggregate(subAggs) + { DocCount = docCount, Meta = meta }; + } + + public override void Write(Utf8JsonWriter writer, SamplerAggregate value, JsonSerializerOptions options) => throw new NotImplementedException(); + } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/ScriptedMetricAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/ScriptedMetricAggregate.g.cs index d1f526a60ae..8997447eb3c 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/ScriptedMetricAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/ScriptedMetricAggregate.g.cs @@ -24,7 +24,7 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.Aggregations { - public sealed partial class ScriptedMetricAggregate : Aggregate + public sealed partial class ScriptedMetricAggregate : IAggregate { [JsonInclude] [JsonPropertyName("meta")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/StatsAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/StatsAggregate.g.cs index c09761a9eea..30435e55e2a 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/StatsAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/StatsAggregate.g.cs @@ -24,7 +24,7 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.Aggregations { - public sealed partial class StatsAggregate : Aggregate + public sealed partial class StatsAggregate : IAggregate { [JsonInclude] [JsonPropertyName("avg")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/StatsBucketAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/StatsBucketAggregate.g.cs index 820bf0c5b56..a2c4fdd63ee 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/StatsBucketAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/StatsBucketAggregate.g.cs @@ -24,7 +24,7 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.Aggregations { - public sealed partial class StatsBucketAggregate : Aggregate + public sealed partial class StatsBucketAggregate : IAggregate { [JsonInclude] [JsonPropertyName("avg")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/StringStatsAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/StringStatsAggregate.g.cs index aa9c9c6763e..e4e527441ec 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/StringStatsAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/StringStatsAggregate.g.cs @@ -24,7 +24,7 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.Aggregations { - public sealed partial class StringStatsAggregate : Aggregate + public sealed partial class StringStatsAggregate : IAggregate { [JsonInclude] [JsonPropertyName("avg_length")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/StringTermsAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/StringTermsAggregate.g.cs index a6963f2f3a8..ed46bf85fdf 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/StringTermsAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/StringTermsAggregate.g.cs @@ -24,7 +24,7 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.Aggregations { - public sealed partial class StringTermsAggregate : Aggregate + public sealed partial class StringTermsAggregate : IAggregate { [JsonInclude] [JsonPropertyName("buckets")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/SumAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/SumAggregate.g.cs index ae59b3e8dc9..7e13c4b6c3b 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/SumAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/SumAggregate.g.cs @@ -24,7 +24,7 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.Aggregations { - public sealed partial class SumAggregate : Aggregate + public sealed partial class SumAggregate : IAggregate { [JsonInclude] [JsonPropertyName("meta")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/TDigestPercentileRanksAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/TDigestPercentileRanksAggregate.g.cs index 9ac44ca99f8..26717ee18d9 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/TDigestPercentileRanksAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/TDigestPercentileRanksAggregate.g.cs @@ -24,7 +24,7 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.Aggregations { - public sealed partial class TDigestPercentileRanksAggregate : Aggregate + public sealed partial class TDigestPercentileRanksAggregate : IAggregate { [JsonInclude] [JsonPropertyName("meta")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/TTestAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/TTestAggregate.g.cs index fd0730d0642..5cc7c544891 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/TTestAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/TTestAggregate.g.cs @@ -24,7 +24,7 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.Aggregations { - public sealed partial class TTestAggregate : Aggregate + public sealed partial class TTestAggregate : IAggregate { [JsonInclude] [JsonPropertyName("meta")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/TopHitsAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/TopHitsAggregate.g.cs index d7929cd9465..18f46f599f0 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/TopHitsAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/TopHitsAggregate.g.cs @@ -24,7 +24,7 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.Aggregations { - public sealed partial class TopHitsAggregate : Aggregate + public sealed partial class TopHitsAggregate : IAggregate { [JsonInclude] [JsonPropertyName("hits")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/TopMetricsAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/TopMetricsAggregate.g.cs index 5ed6633b7a2..2ded2f43a4d 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/TopMetricsAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/TopMetricsAggregate.g.cs @@ -24,7 +24,7 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.Aggregations { - public sealed partial class TopMetricsAggregate : Aggregate + public sealed partial class TopMetricsAggregate : IAggregate { [JsonInclude] [JsonPropertyName("meta")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/ValueCountAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/ValueCountAggregate.g.cs index f022d8103c1..1b8c6809058 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/ValueCountAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/ValueCountAggregate.g.cs @@ -24,7 +24,7 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.Aggregations { - public sealed partial class ValueCountAggregate : Aggregate + public sealed partial class ValueCountAggregate : IAggregate { [JsonInclude] [JsonPropertyName("meta")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/VariableWidthHistogramAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/VariableWidthHistogramAggregate.g.cs index 6180930cc79..d97c5a6d386 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/VariableWidthHistogramAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/VariableWidthHistogramAggregate.g.cs @@ -24,7 +24,7 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.Aggregations { - public sealed partial class VariableWidthHistogramAggregate : Aggregate + public sealed partial class VariableWidthHistogramAggregate : IAggregate { [JsonInclude] [JsonPropertyName("buckets")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/WeightedAvgAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/WeightedAvgAggregate.g.cs index 7188db19aa1..00298ff9612 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/WeightedAvgAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/WeightedAvgAggregate.g.cs @@ -24,7 +24,7 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.Aggregations { - public sealed partial class WeightedAvgAggregate : Aggregate + public sealed partial class WeightedAvgAggregate : IAggregate { [JsonInclude] [JsonPropertyName("meta")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Snapshot/SnapshotInfo.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Snapshot/SnapshotInfo.g.cs index 228089af587..4d5f6a24f43 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Snapshot/SnapshotInfo.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Snapshot/SnapshotInfo.g.cs @@ -64,7 +64,7 @@ public sealed partial class SnapshotInfo [JsonInclude] [JsonPropertyName("indices")] - public IReadOnlyCollection Indices { get; init; } + public IReadOnlyCollection? Indices { get; init; } [JsonInclude] [JsonPropertyName("metadata")] diff --git a/tests/Tests/Serialization/Aggregations/ChildrenAggregateSerializationTests.cs b/tests/Tests/Serialization/Aggregations/ChildrenAggregateSerializationTests.cs new file mode 100644 index 00000000000..d78914a38de --- /dev/null +++ b/tests/Tests/Serialization/Aggregations/ChildrenAggregateSerializationTests.cs @@ -0,0 +1,25 @@ +// 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. + +using System.Linq; + +namespace Tests.Serialization; + +public class ChildrenAggregateSerializationTests : SerializerTestBase +{ + [U] + public void DeserialisesCorrectly() + { + var json = @"{""aggregations"":{""sterms#top-tags"":{""doc_count_error_upper_bound"":0,""sum_other_doc_count"":0,""buckets"":[{""key"":""file-transfer"",""doc_count"":1,""children#to-answers"":{""doc_count"":2,""sterms#top-names"":{""doc_count_error_upper_bound"":0,""sum_other_doc_count"":0,""buckets"":[{""key"":""Sam"",""doc_count"":1},{""key"":""Troll"",""doc_count"":1}]}}}]}}}"; + + var searchResponse = DeserializeJsonString>(json); + + var topTagsTermsAggregate = searchResponse.Aggregations.GetTerms("top-tags"); + var firstTopTagsBucket = topTagsTermsAggregate.Buckets.Item2.Single(); + var childrenAggregate = firstTopTagsBucket.GetChildren("to-answers"); + var topNamesAggregate = childrenAggregate.GetTerms("top-names"); + var firstTopNameBucket = topNamesAggregate.Buckets.Item2.First(); + firstTopNameBucket.Key.Should().Be("Sam"); + } +}