From ec2cc5b0e55d1eb455df1cfe05b6928964f8e6ce Mon Sep 17 00:00:00 2001 From: Steve Gordon Date: Wed, 27 Jul 2022 12:31:17 +0100 Subject: [PATCH] Reintroduce sub-aggregations for bucket aggs --- .../AdjacencyMatrixAggregation.g.cs | 156 +++++++++++++ .../Aggregations/AggregationContainer.g.cs | 49 +++- .../AutoDateHistogramAggregation.g.cs | 111 +++++++++ .../Aggregations/ChildrenAggregation.g.cs | 156 +++++++++++++ .../Aggregations/CompositeAggregation.g.cs | 184 +++++++++++++++ .../DateHistogramAggregation.g.cs | 111 +++++++++ .../Aggregations/DateRangeAggregation.g.cs | 111 +++++++++ .../Aggregations/FiltersAggregation.g.cs | 184 +++++++++++++++ .../Types/Aggregations/GlobalAggregation.g.cs | 142 ++++++++++++ .../Aggregations/HistogramAggregation.g.cs | 111 +++++++++ .../Aggregations/IpRangeAggregation.g.cs | 111 +++++++++ .../Aggregations/MissingAggregation.g.cs | 111 +++++++++ .../Aggregations/MultiTermsAggregation.g.cs | 111 +++++++++ .../Types/Aggregations/NestedAggregation.g.cs | 111 +++++++++ .../Types/Aggregations/ParentAggregation.g.cs | 156 +++++++++++++ .../Types/Aggregations/RangeAggregation.g.cs | 111 +++++++++ .../ReverseNestedAggregation.g.cs | 111 +++++++++ .../Aggregations/SamplerAggregation.g.cs | 156 +++++++++++++ .../Types/Aggregations/TermsAggregation.g.cs | 111 +++++++++ .../DateHistogramAggregationUsageTests.cs | 216 +++++++++--------- 20 files changed, 2505 insertions(+), 115 deletions(-) diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/AdjacencyMatrixAggregation.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/AdjacencyMatrixAggregation.g.cs index ed98db71ab0..95bc1aef62d 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/AdjacencyMatrixAggregation.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/AdjacencyMatrixAggregation.g.cs @@ -67,6 +67,17 @@ public override AdjacencyMatrixAggregation Read(ref Utf8JsonReader reader, Type continue; } + + if (reader.ValueTextEquals("aggs") || reader.ValueTextEquals("aggregations")) + { + var value = JsonSerializer.Deserialize(ref reader, options); + if (value is not null) + { + agg.Aggregations = value; + } + + continue; + } } } @@ -91,6 +102,12 @@ public override void Write(Utf8JsonWriter writer, AdjacencyMatrixAggregation val JsonSerializer.Serialize(writer, value.Meta, options); } + if (value.Aggregations is not null) + { + writer.WritePropertyName("aggregations"); + JsonSerializer.Serialize(writer, value.Aggregations, options); + } + writer.WriteEndObject(); } } @@ -103,6 +120,8 @@ internal AdjacencyMatrixAggregation() { } + public Elastic.Clients.Elasticsearch.Aggregations.AggregationDictionary? Aggregations { get; set; } + public Dictionary? Filters { get; set; } public Dictionary? Meta { get; set; } @@ -110,6 +129,97 @@ internal AdjacencyMatrixAggregation() public override string? Name { get; internal set; } } + public sealed partial class AdjacencyMatrixAggregationDescriptor : SerializableDescriptorBase> + { + internal AdjacencyMatrixAggregationDescriptor(Action> configure) => configure.Invoke(this); + public AdjacencyMatrixAggregationDescriptor() : base() + { + } + + private Elastic.Clients.Elasticsearch.Aggregations.AggregationDictionary? AggregationsValue { get; set; } + + private Elastic.Clients.Elasticsearch.Aggregations.AggregationContainerDescriptor AggregationsDescriptor { get; set; } + + private Action> AggregationsDescriptorAction { get; set; } + + private Dictionary? FiltersValue { get; set; } + + private Dictionary? MetaValue { get; set; } + + public AdjacencyMatrixAggregationDescriptor Aggregations(Elastic.Clients.Elasticsearch.Aggregations.AggregationDictionary? aggregations) + { + AggregationsDescriptor = null; + AggregationsDescriptorAction = null; + AggregationsValue = aggregations; + return Self; + } + + public AdjacencyMatrixAggregationDescriptor Aggregations(Elastic.Clients.Elasticsearch.Aggregations.AggregationContainerDescriptor descriptor) + { + AggregationsValue = null; + AggregationsDescriptorAction = null; + AggregationsDescriptor = descriptor; + return Self; + } + + public AdjacencyMatrixAggregationDescriptor Aggregations(Action> configure) + { + AggregationsValue = null; + AggregationsDescriptor = null; + AggregationsDescriptorAction = configure; + return Self; + } + + public AdjacencyMatrixAggregationDescriptor Filters(Func, FluentDictionary> selector) + { + FiltersValue = selector?.Invoke(new FluentDictionary()); + return Self; + } + + public AdjacencyMatrixAggregationDescriptor Meta(Func, FluentDictionary> selector) + { + MetaValue = selector?.Invoke(new FluentDictionary()); + return Self; + } + + protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) + { + writer.WriteStartObject(); + writer.WritePropertyName("adjacency_matrix"); + writer.WriteStartObject(); + if (FiltersValue is not null) + { + writer.WritePropertyName("filters"); + JsonSerializer.Serialize(writer, FiltersValue, options); + } + + writer.WriteEndObject(); + if (MetaValue is not null) + { + writer.WritePropertyName("meta"); + JsonSerializer.Serialize(writer, MetaValue, options); + } + + if (AggregationsDescriptor is not null) + { + writer.WritePropertyName("aggregations"); + JsonSerializer.Serialize(writer, AggregationsDescriptor, options); + } + else if (AggregationsDescriptorAction is not null) + { + writer.WritePropertyName("aggregations"); + JsonSerializer.Serialize(writer, new AggregationContainerDescriptor(AggregationsDescriptorAction), options); + } + else if (AggregationsValue is not null) + { + writer.WritePropertyName("aggregations"); + JsonSerializer.Serialize(writer, AggregationsValue, options); + } + + writer.WriteEndObject(); + } + } + public sealed partial class AdjacencyMatrixAggregationDescriptor : SerializableDescriptorBase { internal AdjacencyMatrixAggregationDescriptor(Action configure) => configure.Invoke(this); @@ -117,10 +227,40 @@ public AdjacencyMatrixAggregationDescriptor() : base() { } + private Elastic.Clients.Elasticsearch.Aggregations.AggregationDictionary? AggregationsValue { get; set; } + + private Elastic.Clients.Elasticsearch.Aggregations.AggregationContainerDescriptor AggregationsDescriptor { get; set; } + + private Action AggregationsDescriptorAction { get; set; } + private Dictionary? FiltersValue { get; set; } private Dictionary? MetaValue { get; set; } + public AdjacencyMatrixAggregationDescriptor Aggregations(Elastic.Clients.Elasticsearch.Aggregations.AggregationDictionary? aggregations) + { + AggregationsDescriptor = null; + AggregationsDescriptorAction = null; + AggregationsValue = aggregations; + return Self; + } + + public AdjacencyMatrixAggregationDescriptor Aggregations(Elastic.Clients.Elasticsearch.Aggregations.AggregationContainerDescriptor descriptor) + { + AggregationsValue = null; + AggregationsDescriptorAction = null; + AggregationsDescriptor = descriptor; + return Self; + } + + public AdjacencyMatrixAggregationDescriptor Aggregations(Action configure) + { + AggregationsValue = null; + AggregationsDescriptor = null; + AggregationsDescriptorAction = configure; + return Self; + } + public AdjacencyMatrixAggregationDescriptor Filters(Func, FluentDictionary> selector) { FiltersValue = selector?.Invoke(new FluentDictionary()); @@ -151,6 +291,22 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o JsonSerializer.Serialize(writer, MetaValue, options); } + if (AggregationsDescriptor is not null) + { + writer.WritePropertyName("aggregations"); + JsonSerializer.Serialize(writer, AggregationsDescriptor, options); + } + else if (AggregationsDescriptorAction is not null) + { + writer.WritePropertyName("aggregations"); + JsonSerializer.Serialize(writer, new AggregationContainerDescriptor(AggregationsDescriptorAction), options); + } + else if (AggregationsValue is not null) + { + writer.WritePropertyName("aggregations"); + JsonSerializer.Serialize(writer, AggregationsValue, options); + } + writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/AggregationContainer.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/AggregationContainer.g.cs index 6c71210a35d..9462eadf24f 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/AggregationContainer.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/AggregationContainer.g.cs @@ -290,7 +290,7 @@ public AggregationContainerDescriptor() : base() { } - public AggregationContainerDescriptor AdjacencyMatrix(string name, Action configure) + public AggregationContainerDescriptor AdjacencyMatrix(string name, Action> configure) { return SetContainer(name, AggregationContainer.CreateWithAction("adjacency_matrix", configure)); } @@ -315,12 +315,12 @@ public AggregationContainerDescriptor Cardinality(string name, Action return SetContainer(name, AggregationContainer.CreateWithAction("cardinality", configure)); } - public AggregationContainerDescriptor Children(string name, Action configure) + public AggregationContainerDescriptor Children(string name, Action> configure) { return SetContainer(name, AggregationContainer.CreateWithAction("children", configure)); } - public AggregationContainerDescriptor Composite(string name, Action configure) + public AggregationContainerDescriptor Composite(string name, Action> configure) { return SetContainer(name, AggregationContainer.CreateWithAction("composite", configure)); } @@ -355,12 +355,12 @@ public AggregationContainerDescriptor ExtendedStatsBucket(string name return SetContainer(name, AggregationContainer.CreateWithAction("extended_stats_bucket", configure)); } - public AggregationContainerDescriptor Filters(string name, Action configure) + public AggregationContainerDescriptor Filters(string name, Action> configure) { return SetContainer(name, AggregationContainer.CreateWithAction("filters", configure)); } - public AggregationContainerDescriptor Global(string name, Action configure) + public AggregationContainerDescriptor Global(string name, Action> configure) { return SetContainer(name, AggregationContainer.CreateWithAction("global", configure)); } @@ -415,7 +415,7 @@ public AggregationContainerDescriptor Nested(string name, Action Parent(string name, Action configure) + public AggregationContainerDescriptor Parent(string name, Action> configure) { return SetContainer(name, AggregationContainer.CreateWithAction("parent", configure)); } @@ -440,7 +440,7 @@ public AggregationContainerDescriptor ReverseNested(string name, Acti return SetContainer(name, AggregationContainer.CreateWithAction("reverse_nested", configure)); } - public AggregationContainerDescriptor Sampler(string name, Action configure) + public AggregationContainerDescriptor Sampler(string name, Action> configure) { return SetContainer(name, AggregationContainer.CreateWithAction("sampler", configure)); } @@ -518,6 +518,11 @@ public AggregationContainerDescriptor AdjacencyMatrix(string name, Action(string name, Action> configure) + { + return SetContainer(name, AggregationContainer.CreateWithAction("adjacency_matrix", configure)); + } + public AggregationContainerDescriptor AutoDateHistogram(string name, Action configure) { return SetContainer(name, AggregationContainer.CreateWithAction("auto_date_histogram", configure)); @@ -563,11 +568,21 @@ public AggregationContainerDescriptor Children(string name, Action(string name, Action> configure) + { + return SetContainer(name, AggregationContainer.CreateWithAction("children", configure)); + } + public AggregationContainerDescriptor Composite(string name, Action configure) { return SetContainer(name, AggregationContainer.CreateWithAction("composite", configure)); } + public AggregationContainerDescriptor Composite(string name, Action> configure) + { + return SetContainer(name, AggregationContainer.CreateWithAction("composite", configure)); + } + public AggregationContainerDescriptor CumulativeCardinality(string name, Action configure) { return SetContainer(name, AggregationContainer.CreateWithAction("cumulative_cardinality", configure)); @@ -618,11 +633,21 @@ public AggregationContainerDescriptor Filters(string name, Action(string name, Action> configure) + { + return SetContainer(name, AggregationContainer.CreateWithAction("filters", configure)); + } + public AggregationContainerDescriptor Global(string name, Action configure) { return SetContainer(name, AggregationContainer.CreateWithAction("global", configure)); } + public AggregationContainerDescriptor Global(string name, Action> configure) + { + return SetContainer(name, AggregationContainer.CreateWithAction("global", configure)); + } + public AggregationContainerDescriptor Histogram(string name, Action configure) { return SetContainer(name, AggregationContainer.CreateWithAction("histogram", configure)); @@ -728,6 +753,11 @@ public AggregationContainerDescriptor Parent(string name, Action(string name, Action> configure) + { + return SetContainer(name, AggregationContainer.CreateWithAction("parent", configure)); + } + public AggregationContainerDescriptor PercentilesBucket(string name, Action configure) { return SetContainer(name, AggregationContainer.CreateWithAction("percentiles_bucket", configure)); @@ -768,6 +798,11 @@ public AggregationContainerDescriptor Sampler(string name, Action(string name, Action> configure) + { + return SetContainer(name, AggregationContainer.CreateWithAction("sampler", configure)); + } + public AggregationContainerDescriptor ScriptedMetric(string name, Action configure) { return SetContainer(name, AggregationContainer.CreateWithAction("scripted_metric", configure)); diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/AutoDateHistogramAggregation.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/AutoDateHistogramAggregation.g.cs index 6fad552437c..c5867cad31d 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/AutoDateHistogramAggregation.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/AutoDateHistogramAggregation.g.cs @@ -163,6 +163,17 @@ public override AutoDateHistogramAggregation Read(ref Utf8JsonReader reader, Typ continue; } + + if (reader.ValueTextEquals("aggs") || reader.ValueTextEquals("aggregations")) + { + var value = JsonSerializer.Deserialize(ref reader, options); + if (value is not null) + { + agg.Aggregations = value; + } + + continue; + } } } @@ -235,6 +246,12 @@ public override void Write(Utf8JsonWriter writer, AutoDateHistogramAggregation v JsonSerializer.Serialize(writer, value.Meta, options); } + if (value.Aggregations is not null) + { + writer.WritePropertyName("aggregations"); + JsonSerializer.Serialize(writer, value.Aggregations, options); + } + writer.WriteEndObject(); } } @@ -247,6 +264,8 @@ internal AutoDateHistogramAggregation() { } + public Elastic.Clients.Elasticsearch.Aggregations.AggregationDictionary? Aggregations { get; set; } + public int? Buckets { get; set; } public Elastic.Clients.Elasticsearch.Field? Field { get; set; } @@ -277,6 +296,12 @@ public AutoDateHistogramAggregationDescriptor() : base() { } + private Elastic.Clients.Elasticsearch.Aggregations.AggregationDictionary? AggregationsValue { get; set; } + + private Elastic.Clients.Elasticsearch.Aggregations.AggregationContainerDescriptor AggregationsDescriptor { get; set; } + + private Action> AggregationsDescriptorAction { get; set; } + private int? BucketsValue { get; set; } private Elastic.Clients.Elasticsearch.Field? FieldValue { get; set; } @@ -297,6 +322,30 @@ public AutoDateHistogramAggregationDescriptor() : base() private string? TimeZoneValue { get; set; } + public AutoDateHistogramAggregationDescriptor Aggregations(Elastic.Clients.Elasticsearch.Aggregations.AggregationDictionary? aggregations) + { + AggregationsDescriptor = null; + AggregationsDescriptorAction = null; + AggregationsValue = aggregations; + return Self; + } + + public AutoDateHistogramAggregationDescriptor Aggregations(Elastic.Clients.Elasticsearch.Aggregations.AggregationContainerDescriptor descriptor) + { + AggregationsValue = null; + AggregationsDescriptorAction = null; + AggregationsDescriptor = descriptor; + return Self; + } + + public AutoDateHistogramAggregationDescriptor Aggregations(Action> configure) + { + AggregationsValue = null; + AggregationsDescriptor = null; + AggregationsDescriptorAction = configure; + return Self; + } + public AutoDateHistogramAggregationDescriptor Buckets(int? buckets) { BucketsValue = buckets; @@ -429,6 +478,22 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o JsonSerializer.Serialize(writer, MetaValue, options); } + if (AggregationsDescriptor is not null) + { + writer.WritePropertyName("aggregations"); + JsonSerializer.Serialize(writer, AggregationsDescriptor, options); + } + else if (AggregationsDescriptorAction is not null) + { + writer.WritePropertyName("aggregations"); + JsonSerializer.Serialize(writer, new AggregationContainerDescriptor(AggregationsDescriptorAction), options); + } + else if (AggregationsValue is not null) + { + writer.WritePropertyName("aggregations"); + JsonSerializer.Serialize(writer, AggregationsValue, options); + } + writer.WriteEndObject(); } } @@ -440,6 +505,12 @@ public AutoDateHistogramAggregationDescriptor() : base() { } + private Elastic.Clients.Elasticsearch.Aggregations.AggregationDictionary? AggregationsValue { get; set; } + + private Elastic.Clients.Elasticsearch.Aggregations.AggregationContainerDescriptor AggregationsDescriptor { get; set; } + + private Action AggregationsDescriptorAction { get; set; } + private int? BucketsValue { get; set; } private Elastic.Clients.Elasticsearch.Field? FieldValue { get; set; } @@ -460,6 +531,30 @@ public AutoDateHistogramAggregationDescriptor() : base() private string? TimeZoneValue { get; set; } + public AutoDateHistogramAggregationDescriptor Aggregations(Elastic.Clients.Elasticsearch.Aggregations.AggregationDictionary? aggregations) + { + AggregationsDescriptor = null; + AggregationsDescriptorAction = null; + AggregationsValue = aggregations; + return Self; + } + + public AutoDateHistogramAggregationDescriptor Aggregations(Elastic.Clients.Elasticsearch.Aggregations.AggregationContainerDescriptor descriptor) + { + AggregationsValue = null; + AggregationsDescriptorAction = null; + AggregationsDescriptor = descriptor; + return Self; + } + + public AutoDateHistogramAggregationDescriptor Aggregations(Action configure) + { + AggregationsValue = null; + AggregationsDescriptor = null; + AggregationsDescriptorAction = configure; + return Self; + } + public AutoDateHistogramAggregationDescriptor Buckets(int? buckets) { BucketsValue = buckets; @@ -598,6 +693,22 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o JsonSerializer.Serialize(writer, MetaValue, options); } + if (AggregationsDescriptor is not null) + { + writer.WritePropertyName("aggregations"); + JsonSerializer.Serialize(writer, AggregationsDescriptor, options); + } + else if (AggregationsDescriptorAction is not null) + { + writer.WritePropertyName("aggregations"); + JsonSerializer.Serialize(writer, new AggregationContainerDescriptor(AggregationsDescriptorAction), options); + } + else if (AggregationsValue is not null) + { + writer.WritePropertyName("aggregations"); + JsonSerializer.Serialize(writer, AggregationsValue, options); + } + writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/ChildrenAggregation.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/ChildrenAggregation.g.cs index c09b3f19d93..ba017dedeae 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/ChildrenAggregation.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/ChildrenAggregation.g.cs @@ -67,6 +67,17 @@ public override ChildrenAggregation Read(ref Utf8JsonReader reader, Type typeToC continue; } + + if (reader.ValueTextEquals("aggs") || reader.ValueTextEquals("aggregations")) + { + var value = JsonSerializer.Deserialize(ref reader, options); + if (value is not null) + { + agg.Aggregations = value; + } + + continue; + } } } @@ -91,6 +102,12 @@ public override void Write(Utf8JsonWriter writer, ChildrenAggregation value, Jso JsonSerializer.Serialize(writer, value.Meta, options); } + if (value.Aggregations is not null) + { + writer.WritePropertyName("aggregations"); + JsonSerializer.Serialize(writer, value.Aggregations, options); + } + writer.WriteEndObject(); } } @@ -103,6 +120,8 @@ internal ChildrenAggregation() { } + public Elastic.Clients.Elasticsearch.Aggregations.AggregationDictionary? Aggregations { get; set; } + public Dictionary? Meta { get; set; } public override string? Name { get; internal set; } @@ -110,6 +129,97 @@ internal ChildrenAggregation() public string? Type { get; set; } } + public sealed partial class ChildrenAggregationDescriptor : SerializableDescriptorBase> + { + internal ChildrenAggregationDescriptor(Action> configure) => configure.Invoke(this); + public ChildrenAggregationDescriptor() : base() + { + } + + private Elastic.Clients.Elasticsearch.Aggregations.AggregationDictionary? AggregationsValue { get; set; } + + private Elastic.Clients.Elasticsearch.Aggregations.AggregationContainerDescriptor AggregationsDescriptor { get; set; } + + private Action> AggregationsDescriptorAction { get; set; } + + private Dictionary? MetaValue { get; set; } + + private string? TypeValue { get; set; } + + public ChildrenAggregationDescriptor Aggregations(Elastic.Clients.Elasticsearch.Aggregations.AggregationDictionary? aggregations) + { + AggregationsDescriptor = null; + AggregationsDescriptorAction = null; + AggregationsValue = aggregations; + return Self; + } + + public ChildrenAggregationDescriptor Aggregations(Elastic.Clients.Elasticsearch.Aggregations.AggregationContainerDescriptor descriptor) + { + AggregationsValue = null; + AggregationsDescriptorAction = null; + AggregationsDescriptor = descriptor; + return Self; + } + + public ChildrenAggregationDescriptor Aggregations(Action> configure) + { + AggregationsValue = null; + AggregationsDescriptor = null; + AggregationsDescriptorAction = configure; + return Self; + } + + public ChildrenAggregationDescriptor Meta(Func, FluentDictionary> selector) + { + MetaValue = selector?.Invoke(new FluentDictionary()); + return Self; + } + + public ChildrenAggregationDescriptor Type(string? type) + { + TypeValue = type; + return Self; + } + + protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) + { + writer.WriteStartObject(); + writer.WritePropertyName("children"); + writer.WriteStartObject(); + if (TypeValue is not null) + { + writer.WritePropertyName("type"); + JsonSerializer.Serialize(writer, TypeValue, options); + } + + writer.WriteEndObject(); + if (MetaValue is not null) + { + writer.WritePropertyName("meta"); + JsonSerializer.Serialize(writer, MetaValue, options); + } + + if (AggregationsDescriptor is not null) + { + writer.WritePropertyName("aggregations"); + JsonSerializer.Serialize(writer, AggregationsDescriptor, options); + } + else if (AggregationsDescriptorAction is not null) + { + writer.WritePropertyName("aggregations"); + JsonSerializer.Serialize(writer, new AggregationContainerDescriptor(AggregationsDescriptorAction), options); + } + else if (AggregationsValue is not null) + { + writer.WritePropertyName("aggregations"); + JsonSerializer.Serialize(writer, AggregationsValue, options); + } + + writer.WriteEndObject(); + } + } + public sealed partial class ChildrenAggregationDescriptor : SerializableDescriptorBase { internal ChildrenAggregationDescriptor(Action configure) => configure.Invoke(this); @@ -117,10 +227,40 @@ public ChildrenAggregationDescriptor() : base() { } + private Elastic.Clients.Elasticsearch.Aggregations.AggregationDictionary? AggregationsValue { get; set; } + + private Elastic.Clients.Elasticsearch.Aggregations.AggregationContainerDescriptor AggregationsDescriptor { get; set; } + + private Action AggregationsDescriptorAction { get; set; } + private Dictionary? MetaValue { get; set; } private string? TypeValue { get; set; } + public ChildrenAggregationDescriptor Aggregations(Elastic.Clients.Elasticsearch.Aggregations.AggregationDictionary? aggregations) + { + AggregationsDescriptor = null; + AggregationsDescriptorAction = null; + AggregationsValue = aggregations; + return Self; + } + + public ChildrenAggregationDescriptor Aggregations(Elastic.Clients.Elasticsearch.Aggregations.AggregationContainerDescriptor descriptor) + { + AggregationsValue = null; + AggregationsDescriptorAction = null; + AggregationsDescriptor = descriptor; + return Self; + } + + public ChildrenAggregationDescriptor Aggregations(Action configure) + { + AggregationsValue = null; + AggregationsDescriptor = null; + AggregationsDescriptorAction = configure; + return Self; + } + public ChildrenAggregationDescriptor Meta(Func, FluentDictionary> selector) { MetaValue = selector?.Invoke(new FluentDictionary()); @@ -151,6 +291,22 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o JsonSerializer.Serialize(writer, MetaValue, options); } + if (AggregationsDescriptor is not null) + { + writer.WritePropertyName("aggregations"); + JsonSerializer.Serialize(writer, AggregationsDescriptor, options); + } + else if (AggregationsDescriptorAction is not null) + { + writer.WritePropertyName("aggregations"); + JsonSerializer.Serialize(writer, new AggregationContainerDescriptor(AggregationsDescriptorAction), options); + } + else if (AggregationsValue is not null) + { + writer.WritePropertyName("aggregations"); + JsonSerializer.Serialize(writer, AggregationsValue, options); + } + writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/CompositeAggregation.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/CompositeAggregation.g.cs index 75d6d6351bc..3d5e6796d11 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/CompositeAggregation.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/CompositeAggregation.g.cs @@ -91,6 +91,17 @@ public override CompositeAggregation Read(ref Utf8JsonReader reader, Type typeTo continue; } + + if (reader.ValueTextEquals("aggs") || reader.ValueTextEquals("aggregations")) + { + var value = JsonSerializer.Deserialize(ref reader, options); + if (value is not null) + { + agg.Aggregations = value; + } + + continue; + } } } @@ -127,6 +138,12 @@ public override void Write(Utf8JsonWriter writer, CompositeAggregation value, Js JsonSerializer.Serialize(writer, value.Meta, options); } + if (value.Aggregations is not null) + { + writer.WritePropertyName("aggregations"); + JsonSerializer.Serialize(writer, value.Aggregations, options); + } + writer.WriteEndObject(); } } @@ -141,6 +158,8 @@ internal CompositeAggregation() public Dictionary? After { get; set; } + public Elastic.Clients.Elasticsearch.Aggregations.AggregationDictionary? Aggregations { get; set; } + public Dictionary? Meta { get; set; } public override string? Name { get; internal set; } @@ -150,6 +169,125 @@ internal CompositeAggregation() public IEnumerable>? Sources { get; set; } } + public sealed partial class CompositeAggregationDescriptor : SerializableDescriptorBase> + { + internal CompositeAggregationDescriptor(Action> configure) => configure.Invoke(this); + public CompositeAggregationDescriptor() : base() + { + } + + private Elastic.Clients.Elasticsearch.Aggregations.AggregationDictionary? AggregationsValue { get; set; } + + private Elastic.Clients.Elasticsearch.Aggregations.AggregationContainerDescriptor AggregationsDescriptor { get; set; } + + private Action> AggregationsDescriptorAction { get; set; } + + private Dictionary? AfterValue { get; set; } + + private Dictionary? MetaValue { get; set; } + + private int? SizeValue { get; set; } + + private IEnumerable>? SourcesValue { get; set; } + + public CompositeAggregationDescriptor Aggregations(Elastic.Clients.Elasticsearch.Aggregations.AggregationDictionary? aggregations) + { + AggregationsDescriptor = null; + AggregationsDescriptorAction = null; + AggregationsValue = aggregations; + return Self; + } + + public CompositeAggregationDescriptor Aggregations(Elastic.Clients.Elasticsearch.Aggregations.AggregationContainerDescriptor descriptor) + { + AggregationsValue = null; + AggregationsDescriptorAction = null; + AggregationsDescriptor = descriptor; + return Self; + } + + public CompositeAggregationDescriptor Aggregations(Action> configure) + { + AggregationsValue = null; + AggregationsDescriptor = null; + AggregationsDescriptorAction = configure; + return Self; + } + + public CompositeAggregationDescriptor After(Func, FluentDictionary> selector) + { + AfterValue = selector?.Invoke(new FluentDictionary()); + return Self; + } + + public CompositeAggregationDescriptor Meta(Func, FluentDictionary> selector) + { + MetaValue = selector?.Invoke(new FluentDictionary()); + return Self; + } + + public CompositeAggregationDescriptor Size(int? size) + { + SizeValue = size; + return Self; + } + + public CompositeAggregationDescriptor Sources(IEnumerable>? sources) + { + SourcesValue = sources; + return Self; + } + + protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) + { + writer.WriteStartObject(); + writer.WritePropertyName("composite"); + writer.WriteStartObject(); + if (AfterValue is not null) + { + writer.WritePropertyName("after"); + JsonSerializer.Serialize(writer, AfterValue, options); + } + + if (SizeValue.HasValue) + { + writer.WritePropertyName("size"); + writer.WriteNumberValue(SizeValue.Value); + } + + if (SourcesValue is not null) + { + writer.WritePropertyName("sources"); + JsonSerializer.Serialize(writer, SourcesValue, options); + } + + writer.WriteEndObject(); + if (MetaValue is not null) + { + writer.WritePropertyName("meta"); + JsonSerializer.Serialize(writer, MetaValue, options); + } + + if (AggregationsDescriptor is not null) + { + writer.WritePropertyName("aggregations"); + JsonSerializer.Serialize(writer, AggregationsDescriptor, options); + } + else if (AggregationsDescriptorAction is not null) + { + writer.WritePropertyName("aggregations"); + JsonSerializer.Serialize(writer, new AggregationContainerDescriptor(AggregationsDescriptorAction), options); + } + else if (AggregationsValue is not null) + { + writer.WritePropertyName("aggregations"); + JsonSerializer.Serialize(writer, AggregationsValue, options); + } + + writer.WriteEndObject(); + } + } + public sealed partial class CompositeAggregationDescriptor : SerializableDescriptorBase { internal CompositeAggregationDescriptor(Action configure) => configure.Invoke(this); @@ -157,6 +295,12 @@ public CompositeAggregationDescriptor() : base() { } + private Elastic.Clients.Elasticsearch.Aggregations.AggregationDictionary? AggregationsValue { get; set; } + + private Elastic.Clients.Elasticsearch.Aggregations.AggregationContainerDescriptor AggregationsDescriptor { get; set; } + + private Action AggregationsDescriptorAction { get; set; } + private Dictionary? AfterValue { get; set; } private Dictionary? MetaValue { get; set; } @@ -165,6 +309,30 @@ public CompositeAggregationDescriptor() : base() private IEnumerable>? SourcesValue { get; set; } + public CompositeAggregationDescriptor Aggregations(Elastic.Clients.Elasticsearch.Aggregations.AggregationDictionary? aggregations) + { + AggregationsDescriptor = null; + AggregationsDescriptorAction = null; + AggregationsValue = aggregations; + return Self; + } + + public CompositeAggregationDescriptor Aggregations(Elastic.Clients.Elasticsearch.Aggregations.AggregationContainerDescriptor descriptor) + { + AggregationsValue = null; + AggregationsDescriptorAction = null; + AggregationsDescriptor = descriptor; + return Self; + } + + public CompositeAggregationDescriptor Aggregations(Action configure) + { + AggregationsValue = null; + AggregationsDescriptor = null; + AggregationsDescriptorAction = configure; + return Self; + } + public CompositeAggregationDescriptor After(Func, FluentDictionary> selector) { AfterValue = selector?.Invoke(new FluentDictionary()); @@ -219,6 +387,22 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o JsonSerializer.Serialize(writer, MetaValue, options); } + if (AggregationsDescriptor is not null) + { + writer.WritePropertyName("aggregations"); + JsonSerializer.Serialize(writer, AggregationsDescriptor, options); + } + else if (AggregationsDescriptorAction is not null) + { + writer.WritePropertyName("aggregations"); + JsonSerializer.Serialize(writer, new AggregationContainerDescriptor(AggregationsDescriptorAction), options); + } + else if (AggregationsValue is not null) + { + writer.WritePropertyName("aggregations"); + JsonSerializer.Serialize(writer, AggregationsValue, options); + } + writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/DateHistogramAggregation.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/DateHistogramAggregation.g.cs index 0961a9a7d62..8061e419890 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/DateHistogramAggregation.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/DateHistogramAggregation.g.cs @@ -187,6 +187,17 @@ public override DateHistogramAggregation Read(ref Utf8JsonReader reader, Type ty continue; } + + if (reader.ValueTextEquals("aggs") || reader.ValueTextEquals("aggregations")) + { + var value = JsonSerializer.Deserialize(ref reader, options); + if (value is not null) + { + agg.Aggregations = value; + } + + continue; + } } } @@ -271,6 +282,12 @@ public override void Write(Utf8JsonWriter writer, DateHistogramAggregation value JsonSerializer.Serialize(writer, value.Meta, options); } + if (value.Aggregations is not null) + { + writer.WritePropertyName("aggregations"); + JsonSerializer.Serialize(writer, value.Aggregations, options); + } + writer.WriteEndObject(); } } @@ -283,6 +300,8 @@ internal DateHistogramAggregation() { } + public Elastic.Clients.Elasticsearch.Aggregations.AggregationDictionary? Aggregations { get; set; } + public Elastic.Clients.Elasticsearch.Aggregations.CalendarInterval? CalendarInterval { get; set; } public Elastic.Clients.Elasticsearch.Field? Field { get; set; } @@ -318,6 +337,12 @@ public DateHistogramAggregationDescriptor() : base() { } + private Elastic.Clients.Elasticsearch.Aggregations.AggregationDictionary? AggregationsValue { get; set; } + + private Elastic.Clients.Elasticsearch.Aggregations.AggregationContainerDescriptor AggregationsDescriptor { get; set; } + + private Action> AggregationsDescriptorAction { get; set; } + private Elastic.Clients.Elasticsearch.Aggregations.CalendarInterval? CalendarIntervalValue { get; set; } private Elastic.Clients.Elasticsearch.Field? FieldValue { get; set; } @@ -342,6 +367,30 @@ public DateHistogramAggregationDescriptor() : base() private string? TimeZoneValue { get; set; } + public DateHistogramAggregationDescriptor Aggregations(Elastic.Clients.Elasticsearch.Aggregations.AggregationDictionary? aggregations) + { + AggregationsDescriptor = null; + AggregationsDescriptorAction = null; + AggregationsValue = aggregations; + return Self; + } + + public DateHistogramAggregationDescriptor Aggregations(Elastic.Clients.Elasticsearch.Aggregations.AggregationContainerDescriptor descriptor) + { + AggregationsValue = null; + AggregationsDescriptorAction = null; + AggregationsDescriptor = descriptor; + return Self; + } + + public DateHistogramAggregationDescriptor Aggregations(Action> configure) + { + AggregationsValue = null; + AggregationsDescriptor = null; + AggregationsDescriptorAction = configure; + return Self; + } + public DateHistogramAggregationDescriptor CalendarInterval(Elastic.Clients.Elasticsearch.Aggregations.CalendarInterval? calendarInterval) { CalendarIntervalValue = calendarInterval; @@ -498,6 +547,22 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o JsonSerializer.Serialize(writer, MetaValue, options); } + if (AggregationsDescriptor is not null) + { + writer.WritePropertyName("aggregations"); + JsonSerializer.Serialize(writer, AggregationsDescriptor, options); + } + else if (AggregationsDescriptorAction is not null) + { + writer.WritePropertyName("aggregations"); + JsonSerializer.Serialize(writer, new AggregationContainerDescriptor(AggregationsDescriptorAction), options); + } + else if (AggregationsValue is not null) + { + writer.WritePropertyName("aggregations"); + JsonSerializer.Serialize(writer, AggregationsValue, options); + } + writer.WriteEndObject(); } } @@ -509,6 +574,12 @@ public DateHistogramAggregationDescriptor() : base() { } + private Elastic.Clients.Elasticsearch.Aggregations.AggregationDictionary? AggregationsValue { get; set; } + + private Elastic.Clients.Elasticsearch.Aggregations.AggregationContainerDescriptor AggregationsDescriptor { get; set; } + + private Action AggregationsDescriptorAction { get; set; } + private Elastic.Clients.Elasticsearch.Aggregations.CalendarInterval? CalendarIntervalValue { get; set; } private Elastic.Clients.Elasticsearch.Field? FieldValue { get; set; } @@ -533,6 +604,30 @@ public DateHistogramAggregationDescriptor() : base() private string? TimeZoneValue { get; set; } + public DateHistogramAggregationDescriptor Aggregations(Elastic.Clients.Elasticsearch.Aggregations.AggregationDictionary? aggregations) + { + AggregationsDescriptor = null; + AggregationsDescriptorAction = null; + AggregationsValue = aggregations; + return Self; + } + + public DateHistogramAggregationDescriptor Aggregations(Elastic.Clients.Elasticsearch.Aggregations.AggregationContainerDescriptor descriptor) + { + AggregationsValue = null; + AggregationsDescriptorAction = null; + AggregationsDescriptor = descriptor; + return Self; + } + + public DateHistogramAggregationDescriptor Aggregations(Action configure) + { + AggregationsValue = null; + AggregationsDescriptor = null; + AggregationsDescriptorAction = configure; + return Self; + } + public DateHistogramAggregationDescriptor CalendarInterval(Elastic.Clients.Elasticsearch.Aggregations.CalendarInterval? calendarInterval) { CalendarIntervalValue = calendarInterval; @@ -695,6 +790,22 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o JsonSerializer.Serialize(writer, MetaValue, options); } + if (AggregationsDescriptor is not null) + { + writer.WritePropertyName("aggregations"); + JsonSerializer.Serialize(writer, AggregationsDescriptor, options); + } + else if (AggregationsDescriptorAction is not null) + { + writer.WritePropertyName("aggregations"); + JsonSerializer.Serialize(writer, new AggregationContainerDescriptor(AggregationsDescriptorAction), options); + } + else if (AggregationsValue is not null) + { + writer.WritePropertyName("aggregations"); + JsonSerializer.Serialize(writer, AggregationsValue, options); + } + writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/DateRangeAggregation.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/DateRangeAggregation.g.cs index 1018a0f9dc3..76044f50ed7 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/DateRangeAggregation.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/DateRangeAggregation.g.cs @@ -103,6 +103,17 @@ public override DateRangeAggregation Read(ref Utf8JsonReader reader, Type typeTo continue; } + + if (reader.ValueTextEquals("aggs") || reader.ValueTextEquals("aggregations")) + { + var value = JsonSerializer.Deserialize(ref reader, options); + if (value is not null) + { + agg.Aggregations = value; + } + + continue; + } } } @@ -145,6 +156,12 @@ public override void Write(Utf8JsonWriter writer, DateRangeAggregation value, Js JsonSerializer.Serialize(writer, value.Meta, options); } + if (value.Aggregations is not null) + { + writer.WritePropertyName("aggregations"); + JsonSerializer.Serialize(writer, value.Aggregations, options); + } + writer.WriteEndObject(); } } @@ -157,6 +174,8 @@ internal DateRangeAggregation() { } + public Elastic.Clients.Elasticsearch.Aggregations.AggregationDictionary? Aggregations { get; set; } + public Elastic.Clients.Elasticsearch.Field? Field { get; set; } public string? Format { get; set; } @@ -177,6 +196,12 @@ public DateRangeAggregationDescriptor() : base() { } + private Elastic.Clients.Elasticsearch.Aggregations.AggregationDictionary? AggregationsValue { get; set; } + + private Elastic.Clients.Elasticsearch.Aggregations.AggregationContainerDescriptor AggregationsDescriptor { get; set; } + + private Action> AggregationsDescriptorAction { get; set; } + private Elastic.Clients.Elasticsearch.Field? FieldValue { get; set; } private string? FormatValue { get; set; } @@ -193,6 +218,30 @@ public DateRangeAggregationDescriptor() : base() private string? TimeZoneValue { get; set; } + public DateRangeAggregationDescriptor Aggregations(Elastic.Clients.Elasticsearch.Aggregations.AggregationDictionary? aggregations) + { + AggregationsDescriptor = null; + AggregationsDescriptorAction = null; + AggregationsValue = aggregations; + return Self; + } + + public DateRangeAggregationDescriptor Aggregations(Elastic.Clients.Elasticsearch.Aggregations.AggregationContainerDescriptor descriptor) + { + AggregationsValue = null; + AggregationsDescriptorAction = null; + AggregationsDescriptor = descriptor; + return Self; + } + + public DateRangeAggregationDescriptor Aggregations(Action> configure) + { + AggregationsValue = null; + AggregationsDescriptor = null; + AggregationsDescriptorAction = configure; + return Self; + } + public DateRangeAggregationDescriptor Field(Elastic.Clients.Elasticsearch.Field? field) { FieldValue = field; @@ -320,6 +369,22 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o JsonSerializer.Serialize(writer, MetaValue, options); } + if (AggregationsDescriptor is not null) + { + writer.WritePropertyName("aggregations"); + JsonSerializer.Serialize(writer, AggregationsDescriptor, options); + } + else if (AggregationsDescriptorAction is not null) + { + writer.WritePropertyName("aggregations"); + JsonSerializer.Serialize(writer, new AggregationContainerDescriptor(AggregationsDescriptorAction), options); + } + else if (AggregationsValue is not null) + { + writer.WritePropertyName("aggregations"); + JsonSerializer.Serialize(writer, AggregationsValue, options); + } + writer.WriteEndObject(); } } @@ -331,6 +396,12 @@ public DateRangeAggregationDescriptor() : base() { } + private Elastic.Clients.Elasticsearch.Aggregations.AggregationDictionary? AggregationsValue { get; set; } + + private Elastic.Clients.Elasticsearch.Aggregations.AggregationContainerDescriptor AggregationsDescriptor { get; set; } + + private Action AggregationsDescriptorAction { get; set; } + private Elastic.Clients.Elasticsearch.Field? FieldValue { get; set; } private string? FormatValue { get; set; } @@ -347,6 +418,30 @@ public DateRangeAggregationDescriptor() : base() private string? TimeZoneValue { get; set; } + public DateRangeAggregationDescriptor Aggregations(Elastic.Clients.Elasticsearch.Aggregations.AggregationDictionary? aggregations) + { + AggregationsDescriptor = null; + AggregationsDescriptorAction = null; + AggregationsValue = aggregations; + return Self; + } + + public DateRangeAggregationDescriptor Aggregations(Elastic.Clients.Elasticsearch.Aggregations.AggregationContainerDescriptor descriptor) + { + AggregationsValue = null; + AggregationsDescriptorAction = null; + AggregationsDescriptor = descriptor; + return Self; + } + + public DateRangeAggregationDescriptor Aggregations(Action configure) + { + AggregationsValue = null; + AggregationsDescriptor = null; + AggregationsDescriptorAction = configure; + return Self; + } + public DateRangeAggregationDescriptor Field(Elastic.Clients.Elasticsearch.Field? field) { FieldValue = field; @@ -480,6 +575,22 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o JsonSerializer.Serialize(writer, MetaValue, options); } + if (AggregationsDescriptor is not null) + { + writer.WritePropertyName("aggregations"); + JsonSerializer.Serialize(writer, AggregationsDescriptor, options); + } + else if (AggregationsDescriptorAction is not null) + { + writer.WritePropertyName("aggregations"); + JsonSerializer.Serialize(writer, new AggregationContainerDescriptor(AggregationsDescriptorAction), options); + } + else if (AggregationsValue is not null) + { + writer.WritePropertyName("aggregations"); + JsonSerializer.Serialize(writer, AggregationsValue, options); + } + writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/FiltersAggregation.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/FiltersAggregation.g.cs index aed260cccaf..8b3c01f0b7e 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/FiltersAggregation.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/FiltersAggregation.g.cs @@ -91,6 +91,17 @@ public override FiltersAggregation Read(ref Utf8JsonReader reader, Type typeToCo continue; } + + if (reader.ValueTextEquals("aggs") || reader.ValueTextEquals("aggregations")) + { + var value = JsonSerializer.Deserialize(ref reader, options); + if (value is not null) + { + agg.Aggregations = value; + } + + continue; + } } } @@ -127,6 +138,12 @@ public override void Write(Utf8JsonWriter writer, FiltersAggregation value, Json JsonSerializer.Serialize(writer, value.Meta, options); } + if (value.Aggregations is not null) + { + writer.WritePropertyName("aggregations"); + JsonSerializer.Serialize(writer, value.Aggregations, options); + } + writer.WriteEndObject(); } } @@ -139,6 +156,8 @@ internal FiltersAggregation() { } + public Elastic.Clients.Elasticsearch.Aggregations.AggregationDictionary? Aggregations { get; set; } + public Elastic.Clients.Elasticsearch.Aggregations.Buckets? Filters { get; set; } public Dictionary? Meta { get; set; } @@ -150,6 +169,125 @@ internal FiltersAggregation() public string? OtherBucketKey { get; set; } } + public sealed partial class FiltersAggregationDescriptor : SerializableDescriptorBase> + { + internal FiltersAggregationDescriptor(Action> configure) => configure.Invoke(this); + public FiltersAggregationDescriptor() : base() + { + } + + private Elastic.Clients.Elasticsearch.Aggregations.AggregationDictionary? AggregationsValue { get; set; } + + private Elastic.Clients.Elasticsearch.Aggregations.AggregationContainerDescriptor AggregationsDescriptor { get; set; } + + private Action> AggregationsDescriptorAction { get; set; } + + private Elastic.Clients.Elasticsearch.Aggregations.Buckets? FiltersValue { get; set; } + + private Dictionary? MetaValue { get; set; } + + private bool? OtherBucketValue { get; set; } + + private string? OtherBucketKeyValue { get; set; } + + public FiltersAggregationDescriptor Aggregations(Elastic.Clients.Elasticsearch.Aggregations.AggregationDictionary? aggregations) + { + AggregationsDescriptor = null; + AggregationsDescriptorAction = null; + AggregationsValue = aggregations; + return Self; + } + + public FiltersAggregationDescriptor Aggregations(Elastic.Clients.Elasticsearch.Aggregations.AggregationContainerDescriptor descriptor) + { + AggregationsValue = null; + AggregationsDescriptorAction = null; + AggregationsDescriptor = descriptor; + return Self; + } + + public FiltersAggregationDescriptor Aggregations(Action> configure) + { + AggregationsValue = null; + AggregationsDescriptor = null; + AggregationsDescriptorAction = configure; + return Self; + } + + public FiltersAggregationDescriptor Filters(Elastic.Clients.Elasticsearch.Aggregations.Buckets? filters) + { + FiltersValue = filters; + return Self; + } + + public FiltersAggregationDescriptor Meta(Func, FluentDictionary> selector) + { + MetaValue = selector?.Invoke(new FluentDictionary()); + return Self; + } + + public FiltersAggregationDescriptor OtherBucket(bool? otherBucket = true) + { + OtherBucketValue = otherBucket; + return Self; + } + + public FiltersAggregationDescriptor OtherBucketKey(string? otherBucketKey) + { + OtherBucketKeyValue = otherBucketKey; + return Self; + } + + protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) + { + writer.WriteStartObject(); + writer.WritePropertyName("filters"); + writer.WriteStartObject(); + if (FiltersValue is not null) + { + writer.WritePropertyName("filters"); + JsonSerializer.Serialize(writer, FiltersValue, options); + } + + if (OtherBucketValue.HasValue) + { + writer.WritePropertyName("other_bucket"); + writer.WriteBooleanValue(OtherBucketValue.Value); + } + + if (!string.IsNullOrEmpty(OtherBucketKeyValue)) + { + writer.WritePropertyName("other_bucket_key"); + writer.WriteStringValue(OtherBucketKeyValue); + } + + writer.WriteEndObject(); + if (MetaValue is not null) + { + writer.WritePropertyName("meta"); + JsonSerializer.Serialize(writer, MetaValue, options); + } + + if (AggregationsDescriptor is not null) + { + writer.WritePropertyName("aggregations"); + JsonSerializer.Serialize(writer, AggregationsDescriptor, options); + } + else if (AggregationsDescriptorAction is not null) + { + writer.WritePropertyName("aggregations"); + JsonSerializer.Serialize(writer, new AggregationContainerDescriptor(AggregationsDescriptorAction), options); + } + else if (AggregationsValue is not null) + { + writer.WritePropertyName("aggregations"); + JsonSerializer.Serialize(writer, AggregationsValue, options); + } + + writer.WriteEndObject(); + } + } + public sealed partial class FiltersAggregationDescriptor : SerializableDescriptorBase { internal FiltersAggregationDescriptor(Action configure) => configure.Invoke(this); @@ -157,6 +295,12 @@ public FiltersAggregationDescriptor() : base() { } + private Elastic.Clients.Elasticsearch.Aggregations.AggregationDictionary? AggregationsValue { get; set; } + + private Elastic.Clients.Elasticsearch.Aggregations.AggregationContainerDescriptor AggregationsDescriptor { get; set; } + + private Action AggregationsDescriptorAction { get; set; } + private Elastic.Clients.Elasticsearch.Aggregations.Buckets? FiltersValue { get; set; } private Dictionary? MetaValue { get; set; } @@ -165,6 +309,30 @@ public FiltersAggregationDescriptor() : base() private string? OtherBucketKeyValue { get; set; } + public FiltersAggregationDescriptor Aggregations(Elastic.Clients.Elasticsearch.Aggregations.AggregationDictionary? aggregations) + { + AggregationsDescriptor = null; + AggregationsDescriptorAction = null; + AggregationsValue = aggregations; + return Self; + } + + public FiltersAggregationDescriptor Aggregations(Elastic.Clients.Elasticsearch.Aggregations.AggregationContainerDescriptor descriptor) + { + AggregationsValue = null; + AggregationsDescriptorAction = null; + AggregationsDescriptor = descriptor; + return Self; + } + + public FiltersAggregationDescriptor Aggregations(Action configure) + { + AggregationsValue = null; + AggregationsDescriptor = null; + AggregationsDescriptorAction = configure; + return Self; + } + public FiltersAggregationDescriptor Filters(Elastic.Clients.Elasticsearch.Aggregations.Buckets? filters) { FiltersValue = filters; @@ -219,6 +387,22 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o JsonSerializer.Serialize(writer, MetaValue, options); } + if (AggregationsDescriptor is not null) + { + writer.WritePropertyName("aggregations"); + JsonSerializer.Serialize(writer, AggregationsDescriptor, options); + } + else if (AggregationsDescriptorAction is not null) + { + writer.WritePropertyName("aggregations"); + JsonSerializer.Serialize(writer, new AggregationContainerDescriptor(AggregationsDescriptorAction), options); + } + else if (AggregationsValue is not null) + { + writer.WritePropertyName("aggregations"); + JsonSerializer.Serialize(writer, AggregationsValue, options); + } + writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/GlobalAggregation.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/GlobalAggregation.g.cs index 06f4664f689..215f43a50a0 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/GlobalAggregation.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/GlobalAggregation.g.cs @@ -56,6 +56,17 @@ public override GlobalAggregation Read(ref Utf8JsonReader reader, Type typeToCon continue; } + + if (reader.ValueTextEquals("aggs") || reader.ValueTextEquals("aggregations")) + { + var value = JsonSerializer.Deserialize(ref reader, options); + if (value is not null) + { + agg.Aggregations = value; + } + + continue; + } } } @@ -74,6 +85,12 @@ public override void Write(Utf8JsonWriter writer, GlobalAggregation value, JsonS JsonSerializer.Serialize(writer, value.Meta, options); } + if (value.Aggregations is not null) + { + writer.WritePropertyName("aggregations"); + JsonSerializer.Serialize(writer, value.Aggregations, options); + } + writer.WriteEndObject(); } } @@ -86,11 +103,90 @@ internal GlobalAggregation() { } + public Elastic.Clients.Elasticsearch.Aggregations.AggregationDictionary? Aggregations { get; set; } + public Dictionary? Meta { get; set; } public override string? Name { get; internal set; } } + public sealed partial class GlobalAggregationDescriptor : SerializableDescriptorBase> + { + internal GlobalAggregationDescriptor(Action> configure) => configure.Invoke(this); + public GlobalAggregationDescriptor() : base() + { + } + + private Elastic.Clients.Elasticsearch.Aggregations.AggregationDictionary? AggregationsValue { get; set; } + + private Elastic.Clients.Elasticsearch.Aggregations.AggregationContainerDescriptor AggregationsDescriptor { get; set; } + + private Action> AggregationsDescriptorAction { get; set; } + + private Dictionary? MetaValue { get; set; } + + public GlobalAggregationDescriptor Aggregations(Elastic.Clients.Elasticsearch.Aggregations.AggregationDictionary? aggregations) + { + AggregationsDescriptor = null; + AggregationsDescriptorAction = null; + AggregationsValue = aggregations; + return Self; + } + + public GlobalAggregationDescriptor Aggregations(Elastic.Clients.Elasticsearch.Aggregations.AggregationContainerDescriptor descriptor) + { + AggregationsValue = null; + AggregationsDescriptorAction = null; + AggregationsDescriptor = descriptor; + return Self; + } + + public GlobalAggregationDescriptor Aggregations(Action> configure) + { + AggregationsValue = null; + AggregationsDescriptor = null; + AggregationsDescriptorAction = configure; + return Self; + } + + public GlobalAggregationDescriptor Meta(Func, FluentDictionary> selector) + { + MetaValue = selector?.Invoke(new FluentDictionary()); + return Self; + } + + protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) + { + writer.WriteStartObject(); + writer.WritePropertyName("global"); + writer.WriteStartObject(); + writer.WriteEndObject(); + if (MetaValue is not null) + { + writer.WritePropertyName("meta"); + JsonSerializer.Serialize(writer, MetaValue, options); + } + + if (AggregationsDescriptor is not null) + { + writer.WritePropertyName("aggregations"); + JsonSerializer.Serialize(writer, AggregationsDescriptor, options); + } + else if (AggregationsDescriptorAction is not null) + { + writer.WritePropertyName("aggregations"); + JsonSerializer.Serialize(writer, new AggregationContainerDescriptor(AggregationsDescriptorAction), options); + } + else if (AggregationsValue is not null) + { + writer.WritePropertyName("aggregations"); + JsonSerializer.Serialize(writer, AggregationsValue, options); + } + + writer.WriteEndObject(); + } + } + public sealed partial class GlobalAggregationDescriptor : SerializableDescriptorBase { internal GlobalAggregationDescriptor(Action configure) => configure.Invoke(this); @@ -98,8 +194,38 @@ public GlobalAggregationDescriptor() : base() { } + private Elastic.Clients.Elasticsearch.Aggregations.AggregationDictionary? AggregationsValue { get; set; } + + private Elastic.Clients.Elasticsearch.Aggregations.AggregationContainerDescriptor AggregationsDescriptor { get; set; } + + private Action AggregationsDescriptorAction { get; set; } + private Dictionary? MetaValue { get; set; } + public GlobalAggregationDescriptor Aggregations(Elastic.Clients.Elasticsearch.Aggregations.AggregationDictionary? aggregations) + { + AggregationsDescriptor = null; + AggregationsDescriptorAction = null; + AggregationsValue = aggregations; + return Self; + } + + public GlobalAggregationDescriptor Aggregations(Elastic.Clients.Elasticsearch.Aggregations.AggregationContainerDescriptor descriptor) + { + AggregationsValue = null; + AggregationsDescriptorAction = null; + AggregationsDescriptor = descriptor; + return Self; + } + + public GlobalAggregationDescriptor Aggregations(Action configure) + { + AggregationsValue = null; + AggregationsDescriptor = null; + AggregationsDescriptorAction = configure; + return Self; + } + public GlobalAggregationDescriptor Meta(Func, FluentDictionary> selector) { MetaValue = selector?.Invoke(new FluentDictionary()); @@ -118,6 +244,22 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o JsonSerializer.Serialize(writer, MetaValue, options); } + if (AggregationsDescriptor is not null) + { + writer.WritePropertyName("aggregations"); + JsonSerializer.Serialize(writer, AggregationsDescriptor, options); + } + else if (AggregationsDescriptorAction is not null) + { + writer.WritePropertyName("aggregations"); + JsonSerializer.Serialize(writer, new AggregationContainerDescriptor(AggregationsDescriptorAction), options); + } + else if (AggregationsValue is not null) + { + writer.WritePropertyName("aggregations"); + JsonSerializer.Serialize(writer, AggregationsValue, options); + } + writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/HistogramAggregation.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/HistogramAggregation.g.cs index 169d00bb381..26d16d24f4a 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/HistogramAggregation.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/HistogramAggregation.g.cs @@ -151,6 +151,17 @@ public override HistogramAggregation Read(ref Utf8JsonReader reader, Type typeTo continue; } + + if (reader.ValueTextEquals("aggs") || reader.ValueTextEquals("aggregations")) + { + var value = JsonSerializer.Deserialize(ref reader, options); + if (value is not null) + { + agg.Aggregations = value; + } + + continue; + } } } @@ -217,6 +228,12 @@ public override void Write(Utf8JsonWriter writer, HistogramAggregation value, Js JsonSerializer.Serialize(writer, value.Meta, options); } + if (value.Aggregations is not null) + { + writer.WritePropertyName("aggregations"); + JsonSerializer.Serialize(writer, value.Aggregations, options); + } + writer.WriteEndObject(); } } @@ -229,6 +246,8 @@ internal HistogramAggregation() { } + public Elastic.Clients.Elasticsearch.Aggregations.AggregationDictionary? Aggregations { get; set; } + public Elastic.Clients.Elasticsearch.Field? Field { get; set; } public string? Format { get; set; } @@ -258,6 +277,12 @@ public HistogramAggregationDescriptor() : base() { } + private Elastic.Clients.Elasticsearch.Aggregations.AggregationDictionary? AggregationsValue { get; set; } + + private Elastic.Clients.Elasticsearch.Aggregations.AggregationContainerDescriptor AggregationsDescriptor { get; set; } + + private Action> AggregationsDescriptorAction { get; set; } + private Elastic.Clients.Elasticsearch.Field? FieldValue { get; set; } private string? FormatValue { get; set; } @@ -276,6 +301,30 @@ public HistogramAggregationDescriptor() : base() private Elastic.Clients.Elasticsearch.Script? ScriptValue { get; set; } + public HistogramAggregationDescriptor Aggregations(Elastic.Clients.Elasticsearch.Aggregations.AggregationDictionary? aggregations) + { + AggregationsDescriptor = null; + AggregationsDescriptorAction = null; + AggregationsValue = aggregations; + return Self; + } + + public HistogramAggregationDescriptor Aggregations(Elastic.Clients.Elasticsearch.Aggregations.AggregationContainerDescriptor descriptor) + { + AggregationsValue = null; + AggregationsDescriptorAction = null; + AggregationsDescriptor = descriptor; + return Self; + } + + public HistogramAggregationDescriptor Aggregations(Action> configure) + { + AggregationsValue = null; + AggregationsDescriptor = null; + AggregationsDescriptorAction = configure; + return Self; + } + public HistogramAggregationDescriptor Field(Elastic.Clients.Elasticsearch.Field? field) { FieldValue = field; @@ -396,6 +445,22 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o JsonSerializer.Serialize(writer, MetaValue, options); } + if (AggregationsDescriptor is not null) + { + writer.WritePropertyName("aggregations"); + JsonSerializer.Serialize(writer, AggregationsDescriptor, options); + } + else if (AggregationsDescriptorAction is not null) + { + writer.WritePropertyName("aggregations"); + JsonSerializer.Serialize(writer, new AggregationContainerDescriptor(AggregationsDescriptorAction), options); + } + else if (AggregationsValue is not null) + { + writer.WritePropertyName("aggregations"); + JsonSerializer.Serialize(writer, AggregationsValue, options); + } + writer.WriteEndObject(); } } @@ -407,6 +472,12 @@ public HistogramAggregationDescriptor() : base() { } + private Elastic.Clients.Elasticsearch.Aggregations.AggregationDictionary? AggregationsValue { get; set; } + + private Elastic.Clients.Elasticsearch.Aggregations.AggregationContainerDescriptor AggregationsDescriptor { get; set; } + + private Action AggregationsDescriptorAction { get; set; } + private Elastic.Clients.Elasticsearch.Field? FieldValue { get; set; } private string? FormatValue { get; set; } @@ -425,6 +496,30 @@ public HistogramAggregationDescriptor() : base() private Elastic.Clients.Elasticsearch.Script? ScriptValue { get; set; } + public HistogramAggregationDescriptor Aggregations(Elastic.Clients.Elasticsearch.Aggregations.AggregationDictionary? aggregations) + { + AggregationsDescriptor = null; + AggregationsDescriptorAction = null; + AggregationsValue = aggregations; + return Self; + } + + public HistogramAggregationDescriptor Aggregations(Elastic.Clients.Elasticsearch.Aggregations.AggregationContainerDescriptor descriptor) + { + AggregationsValue = null; + AggregationsDescriptorAction = null; + AggregationsDescriptor = descriptor; + return Self; + } + + public HistogramAggregationDescriptor Aggregations(Action configure) + { + AggregationsValue = null; + AggregationsDescriptor = null; + AggregationsDescriptorAction = configure; + return Self; + } + public HistogramAggregationDescriptor Field(Elastic.Clients.Elasticsearch.Field? field) { FieldValue = field; @@ -551,6 +646,22 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o JsonSerializer.Serialize(writer, MetaValue, options); } + if (AggregationsDescriptor is not null) + { + writer.WritePropertyName("aggregations"); + JsonSerializer.Serialize(writer, AggregationsDescriptor, options); + } + else if (AggregationsDescriptorAction is not null) + { + writer.WritePropertyName("aggregations"); + JsonSerializer.Serialize(writer, new AggregationContainerDescriptor(AggregationsDescriptorAction), options); + } + else if (AggregationsValue is not null) + { + writer.WritePropertyName("aggregations"); + JsonSerializer.Serialize(writer, AggregationsValue, options); + } + writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/IpRangeAggregation.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/IpRangeAggregation.g.cs index d41238708b5..e35c360ef24 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/IpRangeAggregation.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/IpRangeAggregation.g.cs @@ -79,6 +79,17 @@ public override IpRangeAggregation Read(ref Utf8JsonReader reader, Type typeToCo continue; } + + if (reader.ValueTextEquals("aggs") || reader.ValueTextEquals("aggregations")) + { + var value = JsonSerializer.Deserialize(ref reader, options); + if (value is not null) + { + agg.Aggregations = value; + } + + continue; + } } } @@ -109,6 +120,12 @@ public override void Write(Utf8JsonWriter writer, IpRangeAggregation value, Json JsonSerializer.Serialize(writer, value.Meta, options); } + if (value.Aggregations is not null) + { + writer.WritePropertyName("aggregations"); + JsonSerializer.Serialize(writer, value.Aggregations, options); + } + writer.WriteEndObject(); } } @@ -121,6 +138,8 @@ internal IpRangeAggregation() { } + public Elastic.Clients.Elasticsearch.Aggregations.AggregationDictionary? Aggregations { get; set; } + public Elastic.Clients.Elasticsearch.Field? Field { get; set; } public Dictionary? Meta { get; set; } @@ -137,6 +156,12 @@ public IpRangeAggregationDescriptor() : base() { } + private Elastic.Clients.Elasticsearch.Aggregations.AggregationDictionary? AggregationsValue { get; set; } + + private Elastic.Clients.Elasticsearch.Aggregations.AggregationContainerDescriptor AggregationsDescriptor { get; set; } + + private Action> AggregationsDescriptorAction { get; set; } + private Elastic.Clients.Elasticsearch.Field? FieldValue { get; set; } private Dictionary? MetaValue { get; set; } @@ -149,6 +174,30 @@ public IpRangeAggregationDescriptor() : base() private Action[] RangesDescriptorActions { get; set; } + public IpRangeAggregationDescriptor Aggregations(Elastic.Clients.Elasticsearch.Aggregations.AggregationDictionary? aggregations) + { + AggregationsDescriptor = null; + AggregationsDescriptorAction = null; + AggregationsValue = aggregations; + return Self; + } + + public IpRangeAggregationDescriptor Aggregations(Elastic.Clients.Elasticsearch.Aggregations.AggregationContainerDescriptor descriptor) + { + AggregationsValue = null; + AggregationsDescriptorAction = null; + AggregationsDescriptor = descriptor; + return Self; + } + + public IpRangeAggregationDescriptor Aggregations(Action> configure) + { + AggregationsValue = null; + AggregationsDescriptor = null; + AggregationsDescriptorAction = configure; + return Self; + } + public IpRangeAggregationDescriptor Field(Elastic.Clients.Elasticsearch.Field? field) { FieldValue = field; @@ -252,6 +301,22 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o JsonSerializer.Serialize(writer, MetaValue, options); } + if (AggregationsDescriptor is not null) + { + writer.WritePropertyName("aggregations"); + JsonSerializer.Serialize(writer, AggregationsDescriptor, options); + } + else if (AggregationsDescriptorAction is not null) + { + writer.WritePropertyName("aggregations"); + JsonSerializer.Serialize(writer, new AggregationContainerDescriptor(AggregationsDescriptorAction), options); + } + else if (AggregationsValue is not null) + { + writer.WritePropertyName("aggregations"); + JsonSerializer.Serialize(writer, AggregationsValue, options); + } + writer.WriteEndObject(); } } @@ -263,6 +328,12 @@ public IpRangeAggregationDescriptor() : base() { } + private Elastic.Clients.Elasticsearch.Aggregations.AggregationDictionary? AggregationsValue { get; set; } + + private Elastic.Clients.Elasticsearch.Aggregations.AggregationContainerDescriptor AggregationsDescriptor { get; set; } + + private Action AggregationsDescriptorAction { get; set; } + private Elastic.Clients.Elasticsearch.Field? FieldValue { get; set; } private Dictionary? MetaValue { get; set; } @@ -275,6 +346,30 @@ public IpRangeAggregationDescriptor() : base() private Action[] RangesDescriptorActions { get; set; } + public IpRangeAggregationDescriptor Aggregations(Elastic.Clients.Elasticsearch.Aggregations.AggregationDictionary? aggregations) + { + AggregationsDescriptor = null; + AggregationsDescriptorAction = null; + AggregationsValue = aggregations; + return Self; + } + + public IpRangeAggregationDescriptor Aggregations(Elastic.Clients.Elasticsearch.Aggregations.AggregationContainerDescriptor descriptor) + { + AggregationsValue = null; + AggregationsDescriptorAction = null; + AggregationsDescriptor = descriptor; + return Self; + } + + public IpRangeAggregationDescriptor Aggregations(Action configure) + { + AggregationsValue = null; + AggregationsDescriptor = null; + AggregationsDescriptorAction = configure; + return Self; + } + public IpRangeAggregationDescriptor Field(Elastic.Clients.Elasticsearch.Field? field) { FieldValue = field; @@ -384,6 +479,22 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o JsonSerializer.Serialize(writer, MetaValue, options); } + if (AggregationsDescriptor is not null) + { + writer.WritePropertyName("aggregations"); + JsonSerializer.Serialize(writer, AggregationsDescriptor, options); + } + else if (AggregationsDescriptorAction is not null) + { + writer.WritePropertyName("aggregations"); + JsonSerializer.Serialize(writer, new AggregationContainerDescriptor(AggregationsDescriptorAction), options); + } + else if (AggregationsValue is not null) + { + writer.WritePropertyName("aggregations"); + JsonSerializer.Serialize(writer, AggregationsValue, options); + } + writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/MissingAggregation.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/MissingAggregation.g.cs index 0bc05d7b2f4..5d24a220ad2 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/MissingAggregation.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/MissingAggregation.g.cs @@ -67,6 +67,17 @@ public override MissingAggregation Read(ref Utf8JsonReader reader, Type typeToCo continue; } + + if (reader.ValueTextEquals("aggs") || reader.ValueTextEquals("aggregations")) + { + var value = JsonSerializer.Deserialize(ref reader, options); + if (value is not null) + { + agg.Aggregations = value; + } + + continue; + } } } @@ -91,6 +102,12 @@ public override void Write(Utf8JsonWriter writer, MissingAggregation value, Json JsonSerializer.Serialize(writer, value.Meta, options); } + if (value.Aggregations is not null) + { + writer.WritePropertyName("aggregations"); + JsonSerializer.Serialize(writer, value.Aggregations, options); + } + writer.WriteEndObject(); } } @@ -103,6 +120,8 @@ internal MissingAggregation() { } + public Elastic.Clients.Elasticsearch.Aggregations.AggregationDictionary? Aggregations { get; set; } + public Elastic.Clients.Elasticsearch.Field? Field { get; set; } public Dictionary? Meta { get; set; } @@ -117,10 +136,40 @@ public MissingAggregationDescriptor() : base() { } + private Elastic.Clients.Elasticsearch.Aggregations.AggregationDictionary? AggregationsValue { get; set; } + + private Elastic.Clients.Elasticsearch.Aggregations.AggregationContainerDescriptor AggregationsDescriptor { get; set; } + + private Action> AggregationsDescriptorAction { get; set; } + private Elastic.Clients.Elasticsearch.Field? FieldValue { get; set; } private Dictionary? MetaValue { get; set; } + public MissingAggregationDescriptor Aggregations(Elastic.Clients.Elasticsearch.Aggregations.AggregationDictionary? aggregations) + { + AggregationsDescriptor = null; + AggregationsDescriptorAction = null; + AggregationsValue = aggregations; + return Self; + } + + public MissingAggregationDescriptor Aggregations(Elastic.Clients.Elasticsearch.Aggregations.AggregationContainerDescriptor descriptor) + { + AggregationsValue = null; + AggregationsDescriptorAction = null; + AggregationsDescriptor = descriptor; + return Self; + } + + public MissingAggregationDescriptor Aggregations(Action> configure) + { + AggregationsValue = null; + AggregationsDescriptor = null; + AggregationsDescriptorAction = configure; + return Self; + } + public MissingAggregationDescriptor Field(Elastic.Clients.Elasticsearch.Field? field) { FieldValue = field; @@ -157,6 +206,22 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o JsonSerializer.Serialize(writer, MetaValue, options); } + if (AggregationsDescriptor is not null) + { + writer.WritePropertyName("aggregations"); + JsonSerializer.Serialize(writer, AggregationsDescriptor, options); + } + else if (AggregationsDescriptorAction is not null) + { + writer.WritePropertyName("aggregations"); + JsonSerializer.Serialize(writer, new AggregationContainerDescriptor(AggregationsDescriptorAction), options); + } + else if (AggregationsValue is not null) + { + writer.WritePropertyName("aggregations"); + JsonSerializer.Serialize(writer, AggregationsValue, options); + } + writer.WriteEndObject(); } } @@ -168,10 +233,40 @@ public MissingAggregationDescriptor() : base() { } + private Elastic.Clients.Elasticsearch.Aggregations.AggregationDictionary? AggregationsValue { get; set; } + + private Elastic.Clients.Elasticsearch.Aggregations.AggregationContainerDescriptor AggregationsDescriptor { get; set; } + + private Action AggregationsDescriptorAction { get; set; } + private Elastic.Clients.Elasticsearch.Field? FieldValue { get; set; } private Dictionary? MetaValue { get; set; } + public MissingAggregationDescriptor Aggregations(Elastic.Clients.Elasticsearch.Aggregations.AggregationDictionary? aggregations) + { + AggregationsDescriptor = null; + AggregationsDescriptorAction = null; + AggregationsValue = aggregations; + return Self; + } + + public MissingAggregationDescriptor Aggregations(Elastic.Clients.Elasticsearch.Aggregations.AggregationContainerDescriptor descriptor) + { + AggregationsValue = null; + AggregationsDescriptorAction = null; + AggregationsDescriptor = descriptor; + return Self; + } + + public MissingAggregationDescriptor Aggregations(Action configure) + { + AggregationsValue = null; + AggregationsDescriptor = null; + AggregationsDescriptorAction = configure; + return Self; + } + public MissingAggregationDescriptor Field(Elastic.Clients.Elasticsearch.Field? field) { FieldValue = field; @@ -214,6 +309,22 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o JsonSerializer.Serialize(writer, MetaValue, options); } + if (AggregationsDescriptor is not null) + { + writer.WritePropertyName("aggregations"); + JsonSerializer.Serialize(writer, AggregationsDescriptor, options); + } + else if (AggregationsDescriptorAction is not null) + { + writer.WritePropertyName("aggregations"); + JsonSerializer.Serialize(writer, new AggregationContainerDescriptor(AggregationsDescriptorAction), options); + } + else if (AggregationsValue is not null) + { + writer.WritePropertyName("aggregations"); + JsonSerializer.Serialize(writer, AggregationsValue, options); + } + writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/MultiTermsAggregation.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/MultiTermsAggregation.g.cs index 8f60221cca2..3eab598aad2 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/MultiTermsAggregation.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/MultiTermsAggregation.g.cs @@ -151,6 +151,17 @@ public override MultiTermsAggregation Read(ref Utf8JsonReader reader, Type typeT continue; } + + if (reader.ValueTextEquals("aggs") || reader.ValueTextEquals("aggregations")) + { + var value = JsonSerializer.Deserialize(ref reader, options); + if (value is not null) + { + agg.Aggregations = value; + } + + continue; + } } } @@ -213,6 +224,12 @@ public override void Write(Utf8JsonWriter writer, MultiTermsAggregation value, J JsonSerializer.Serialize(writer, value.Meta, options); } + if (value.Aggregations is not null) + { + writer.WritePropertyName("aggregations"); + JsonSerializer.Serialize(writer, value.Aggregations, options); + } + writer.WriteEndObject(); } } @@ -225,6 +242,8 @@ internal MultiTermsAggregation() { } + public Elastic.Clients.Elasticsearch.Aggregations.AggregationDictionary? Aggregations { get; set; } + public Elastic.Clients.Elasticsearch.Aggregations.TermsAggregationCollectMode? CollectMode { get; set; } public Dictionary? Meta { get; set; } @@ -254,6 +273,12 @@ public MultiTermsAggregationDescriptor() : base() { } + private Elastic.Clients.Elasticsearch.Aggregations.AggregationDictionary? AggregationsValue { get; set; } + + private Elastic.Clients.Elasticsearch.Aggregations.AggregationContainerDescriptor AggregationsDescriptor { get; set; } + + private Action> AggregationsDescriptorAction { get; set; } + private IEnumerable TermsValue { get; set; } private MultiTermLookupDescriptor TermsDescriptor { get; set; } @@ -278,6 +303,30 @@ public MultiTermsAggregationDescriptor() : base() private int? SizeValue { get; set; } + public MultiTermsAggregationDescriptor Aggregations(Elastic.Clients.Elasticsearch.Aggregations.AggregationDictionary? aggregations) + { + AggregationsDescriptor = null; + AggregationsDescriptorAction = null; + AggregationsValue = aggregations; + return Self; + } + + public MultiTermsAggregationDescriptor Aggregations(Elastic.Clients.Elasticsearch.Aggregations.AggregationContainerDescriptor descriptor) + { + AggregationsValue = null; + AggregationsDescriptorAction = null; + AggregationsDescriptor = descriptor; + return Self; + } + + public MultiTermsAggregationDescriptor Aggregations(Action> configure) + { + AggregationsValue = null; + AggregationsDescriptor = null; + AggregationsDescriptorAction = configure; + return Self; + } + public MultiTermsAggregationDescriptor Terms(IEnumerable terms) { TermsDescriptor = null; @@ -447,6 +496,22 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o JsonSerializer.Serialize(writer, MetaValue, options); } + if (AggregationsDescriptor is not null) + { + writer.WritePropertyName("aggregations"); + JsonSerializer.Serialize(writer, AggregationsDescriptor, options); + } + else if (AggregationsDescriptorAction is not null) + { + writer.WritePropertyName("aggregations"); + JsonSerializer.Serialize(writer, new AggregationContainerDescriptor(AggregationsDescriptorAction), options); + } + else if (AggregationsValue is not null) + { + writer.WritePropertyName("aggregations"); + JsonSerializer.Serialize(writer, AggregationsValue, options); + } + writer.WriteEndObject(); } } @@ -458,6 +523,12 @@ public MultiTermsAggregationDescriptor() : base() { } + private Elastic.Clients.Elasticsearch.Aggregations.AggregationDictionary? AggregationsValue { get; set; } + + private Elastic.Clients.Elasticsearch.Aggregations.AggregationContainerDescriptor AggregationsDescriptor { get; set; } + + private Action AggregationsDescriptorAction { get; set; } + private IEnumerable TermsValue { get; set; } private MultiTermLookupDescriptor TermsDescriptor { get; set; } @@ -482,6 +553,30 @@ public MultiTermsAggregationDescriptor() : base() private int? SizeValue { get; set; } + public MultiTermsAggregationDescriptor Aggregations(Elastic.Clients.Elasticsearch.Aggregations.AggregationDictionary? aggregations) + { + AggregationsDescriptor = null; + AggregationsDescriptorAction = null; + AggregationsValue = aggregations; + return Self; + } + + public MultiTermsAggregationDescriptor Aggregations(Elastic.Clients.Elasticsearch.Aggregations.AggregationContainerDescriptor descriptor) + { + AggregationsValue = null; + AggregationsDescriptorAction = null; + AggregationsDescriptor = descriptor; + return Self; + } + + public MultiTermsAggregationDescriptor Aggregations(Action configure) + { + AggregationsValue = null; + AggregationsDescriptor = null; + AggregationsDescriptorAction = configure; + return Self; + } + public MultiTermsAggregationDescriptor Terms(IEnumerable terms) { TermsDescriptor = null; @@ -651,6 +746,22 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o JsonSerializer.Serialize(writer, MetaValue, options); } + if (AggregationsDescriptor is not null) + { + writer.WritePropertyName("aggregations"); + JsonSerializer.Serialize(writer, AggregationsDescriptor, options); + } + else if (AggregationsDescriptorAction is not null) + { + writer.WritePropertyName("aggregations"); + JsonSerializer.Serialize(writer, new AggregationContainerDescriptor(AggregationsDescriptorAction), options); + } + else if (AggregationsValue is not null) + { + writer.WritePropertyName("aggregations"); + JsonSerializer.Serialize(writer, AggregationsValue, options); + } + writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/NestedAggregation.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/NestedAggregation.g.cs index 6f17d05abc5..58f74cb8cb7 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/NestedAggregation.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/NestedAggregation.g.cs @@ -67,6 +67,17 @@ public override NestedAggregation Read(ref Utf8JsonReader reader, Type typeToCon continue; } + + if (reader.ValueTextEquals("aggs") || reader.ValueTextEquals("aggregations")) + { + var value = JsonSerializer.Deserialize(ref reader, options); + if (value is not null) + { + agg.Aggregations = value; + } + + continue; + } } } @@ -91,6 +102,12 @@ public override void Write(Utf8JsonWriter writer, NestedAggregation value, JsonS JsonSerializer.Serialize(writer, value.Meta, options); } + if (value.Aggregations is not null) + { + writer.WritePropertyName("aggregations"); + JsonSerializer.Serialize(writer, value.Aggregations, options); + } + writer.WriteEndObject(); } } @@ -103,6 +120,8 @@ internal NestedAggregation() { } + public Elastic.Clients.Elasticsearch.Aggregations.AggregationDictionary? Aggregations { get; set; } + public Dictionary? Meta { get; set; } public override string? Name { get; internal set; } @@ -117,10 +136,40 @@ public NestedAggregationDescriptor() : base() { } + private Elastic.Clients.Elasticsearch.Aggregations.AggregationDictionary? AggregationsValue { get; set; } + + private Elastic.Clients.Elasticsearch.Aggregations.AggregationContainerDescriptor AggregationsDescriptor { get; set; } + + private Action> AggregationsDescriptorAction { get; set; } + private Dictionary? MetaValue { get; set; } private Elastic.Clients.Elasticsearch.Field? PathValue { get; set; } + public NestedAggregationDescriptor Aggregations(Elastic.Clients.Elasticsearch.Aggregations.AggregationDictionary? aggregations) + { + AggregationsDescriptor = null; + AggregationsDescriptorAction = null; + AggregationsValue = aggregations; + return Self; + } + + public NestedAggregationDescriptor Aggregations(Elastic.Clients.Elasticsearch.Aggregations.AggregationContainerDescriptor descriptor) + { + AggregationsValue = null; + AggregationsDescriptorAction = null; + AggregationsDescriptor = descriptor; + return Self; + } + + public NestedAggregationDescriptor Aggregations(Action> configure) + { + AggregationsValue = null; + AggregationsDescriptor = null; + AggregationsDescriptorAction = configure; + return Self; + } + public NestedAggregationDescriptor Meta(Func, FluentDictionary> selector) { MetaValue = selector?.Invoke(new FluentDictionary()); @@ -157,6 +206,22 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o JsonSerializer.Serialize(writer, MetaValue, options); } + if (AggregationsDescriptor is not null) + { + writer.WritePropertyName("aggregations"); + JsonSerializer.Serialize(writer, AggregationsDescriptor, options); + } + else if (AggregationsDescriptorAction is not null) + { + writer.WritePropertyName("aggregations"); + JsonSerializer.Serialize(writer, new AggregationContainerDescriptor(AggregationsDescriptorAction), options); + } + else if (AggregationsValue is not null) + { + writer.WritePropertyName("aggregations"); + JsonSerializer.Serialize(writer, AggregationsValue, options); + } + writer.WriteEndObject(); } } @@ -168,10 +233,40 @@ public NestedAggregationDescriptor() : base() { } + private Elastic.Clients.Elasticsearch.Aggregations.AggregationDictionary? AggregationsValue { get; set; } + + private Elastic.Clients.Elasticsearch.Aggregations.AggregationContainerDescriptor AggregationsDescriptor { get; set; } + + private Action AggregationsDescriptorAction { get; set; } + private Dictionary? MetaValue { get; set; } private Elastic.Clients.Elasticsearch.Field? PathValue { get; set; } + public NestedAggregationDescriptor Aggregations(Elastic.Clients.Elasticsearch.Aggregations.AggregationDictionary? aggregations) + { + AggregationsDescriptor = null; + AggregationsDescriptorAction = null; + AggregationsValue = aggregations; + return Self; + } + + public NestedAggregationDescriptor Aggregations(Elastic.Clients.Elasticsearch.Aggregations.AggregationContainerDescriptor descriptor) + { + AggregationsValue = null; + AggregationsDescriptorAction = null; + AggregationsDescriptor = descriptor; + return Self; + } + + public NestedAggregationDescriptor Aggregations(Action configure) + { + AggregationsValue = null; + AggregationsDescriptor = null; + AggregationsDescriptorAction = configure; + return Self; + } + public NestedAggregationDescriptor Meta(Func, FluentDictionary> selector) { MetaValue = selector?.Invoke(new FluentDictionary()); @@ -214,6 +309,22 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o JsonSerializer.Serialize(writer, MetaValue, options); } + if (AggregationsDescriptor is not null) + { + writer.WritePropertyName("aggregations"); + JsonSerializer.Serialize(writer, AggregationsDescriptor, options); + } + else if (AggregationsDescriptorAction is not null) + { + writer.WritePropertyName("aggregations"); + JsonSerializer.Serialize(writer, new AggregationContainerDescriptor(AggregationsDescriptorAction), options); + } + else if (AggregationsValue is not null) + { + writer.WritePropertyName("aggregations"); + JsonSerializer.Serialize(writer, AggregationsValue, options); + } + writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/ParentAggregation.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/ParentAggregation.g.cs index 7dc0c5b02d7..f37db986ffb 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/ParentAggregation.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/ParentAggregation.g.cs @@ -67,6 +67,17 @@ public override ParentAggregation Read(ref Utf8JsonReader reader, Type typeToCon continue; } + + if (reader.ValueTextEquals("aggs") || reader.ValueTextEquals("aggregations")) + { + var value = JsonSerializer.Deserialize(ref reader, options); + if (value is not null) + { + agg.Aggregations = value; + } + + continue; + } } } @@ -91,6 +102,12 @@ public override void Write(Utf8JsonWriter writer, ParentAggregation value, JsonS JsonSerializer.Serialize(writer, value.Meta, options); } + if (value.Aggregations is not null) + { + writer.WritePropertyName("aggregations"); + JsonSerializer.Serialize(writer, value.Aggregations, options); + } + writer.WriteEndObject(); } } @@ -103,6 +120,8 @@ internal ParentAggregation() { } + public Elastic.Clients.Elasticsearch.Aggregations.AggregationDictionary? Aggregations { get; set; } + public Dictionary? Meta { get; set; } public override string? Name { get; internal set; } @@ -110,6 +129,97 @@ internal ParentAggregation() public string? Type { get; set; } } + public sealed partial class ParentAggregationDescriptor : SerializableDescriptorBase> + { + internal ParentAggregationDescriptor(Action> configure) => configure.Invoke(this); + public ParentAggregationDescriptor() : base() + { + } + + private Elastic.Clients.Elasticsearch.Aggregations.AggregationDictionary? AggregationsValue { get; set; } + + private Elastic.Clients.Elasticsearch.Aggregations.AggregationContainerDescriptor AggregationsDescriptor { get; set; } + + private Action> AggregationsDescriptorAction { get; set; } + + private Dictionary? MetaValue { get; set; } + + private string? TypeValue { get; set; } + + public ParentAggregationDescriptor Aggregations(Elastic.Clients.Elasticsearch.Aggregations.AggregationDictionary? aggregations) + { + AggregationsDescriptor = null; + AggregationsDescriptorAction = null; + AggregationsValue = aggregations; + return Self; + } + + public ParentAggregationDescriptor Aggregations(Elastic.Clients.Elasticsearch.Aggregations.AggregationContainerDescriptor descriptor) + { + AggregationsValue = null; + AggregationsDescriptorAction = null; + AggregationsDescriptor = descriptor; + return Self; + } + + public ParentAggregationDescriptor Aggregations(Action> configure) + { + AggregationsValue = null; + AggregationsDescriptor = null; + AggregationsDescriptorAction = configure; + return Self; + } + + public ParentAggregationDescriptor Meta(Func, FluentDictionary> selector) + { + MetaValue = selector?.Invoke(new FluentDictionary()); + return Self; + } + + public ParentAggregationDescriptor Type(string? type) + { + TypeValue = type; + return Self; + } + + protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) + { + writer.WriteStartObject(); + writer.WritePropertyName("parent"); + writer.WriteStartObject(); + if (TypeValue is not null) + { + writer.WritePropertyName("type"); + JsonSerializer.Serialize(writer, TypeValue, options); + } + + writer.WriteEndObject(); + if (MetaValue is not null) + { + writer.WritePropertyName("meta"); + JsonSerializer.Serialize(writer, MetaValue, options); + } + + if (AggregationsDescriptor is not null) + { + writer.WritePropertyName("aggregations"); + JsonSerializer.Serialize(writer, AggregationsDescriptor, options); + } + else if (AggregationsDescriptorAction is not null) + { + writer.WritePropertyName("aggregations"); + JsonSerializer.Serialize(writer, new AggregationContainerDescriptor(AggregationsDescriptorAction), options); + } + else if (AggregationsValue is not null) + { + writer.WritePropertyName("aggregations"); + JsonSerializer.Serialize(writer, AggregationsValue, options); + } + + writer.WriteEndObject(); + } + } + public sealed partial class ParentAggregationDescriptor : SerializableDescriptorBase { internal ParentAggregationDescriptor(Action configure) => configure.Invoke(this); @@ -117,10 +227,40 @@ public ParentAggregationDescriptor() : base() { } + private Elastic.Clients.Elasticsearch.Aggregations.AggregationDictionary? AggregationsValue { get; set; } + + private Elastic.Clients.Elasticsearch.Aggregations.AggregationContainerDescriptor AggregationsDescriptor { get; set; } + + private Action AggregationsDescriptorAction { get; set; } + private Dictionary? MetaValue { get; set; } private string? TypeValue { get; set; } + public ParentAggregationDescriptor Aggregations(Elastic.Clients.Elasticsearch.Aggregations.AggregationDictionary? aggregations) + { + AggregationsDescriptor = null; + AggregationsDescriptorAction = null; + AggregationsValue = aggregations; + return Self; + } + + public ParentAggregationDescriptor Aggregations(Elastic.Clients.Elasticsearch.Aggregations.AggregationContainerDescriptor descriptor) + { + AggregationsValue = null; + AggregationsDescriptorAction = null; + AggregationsDescriptor = descriptor; + return Self; + } + + public ParentAggregationDescriptor Aggregations(Action configure) + { + AggregationsValue = null; + AggregationsDescriptor = null; + AggregationsDescriptorAction = configure; + return Self; + } + public ParentAggregationDescriptor Meta(Func, FluentDictionary> selector) { MetaValue = selector?.Invoke(new FluentDictionary()); @@ -151,6 +291,22 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o JsonSerializer.Serialize(writer, MetaValue, options); } + if (AggregationsDescriptor is not null) + { + writer.WritePropertyName("aggregations"); + JsonSerializer.Serialize(writer, AggregationsDescriptor, options); + } + else if (AggregationsDescriptorAction is not null) + { + writer.WritePropertyName("aggregations"); + JsonSerializer.Serialize(writer, new AggregationContainerDescriptor(AggregationsDescriptorAction), options); + } + else if (AggregationsValue is not null) + { + writer.WritePropertyName("aggregations"); + JsonSerializer.Serialize(writer, AggregationsValue, options); + } + writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/RangeAggregation.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/RangeAggregation.g.cs index ab3ce8535e1..b76c8f1e444 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/RangeAggregation.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/RangeAggregation.g.cs @@ -115,6 +115,17 @@ public override RangeAggregation Read(ref Utf8JsonReader reader, Type typeToConv continue; } + + if (reader.ValueTextEquals("aggs") || reader.ValueTextEquals("aggregations")) + { + var value = JsonSerializer.Deserialize(ref reader, options); + if (value is not null) + { + agg.Aggregations = value; + } + + continue; + } } } @@ -163,6 +174,12 @@ public override void Write(Utf8JsonWriter writer, RangeAggregation value, JsonSe JsonSerializer.Serialize(writer, value.Meta, options); } + if (value.Aggregations is not null) + { + writer.WritePropertyName("aggregations"); + JsonSerializer.Serialize(writer, value.Aggregations, options); + } + writer.WriteEndObject(); } } @@ -175,6 +192,8 @@ internal RangeAggregation() { } + public Elastic.Clients.Elasticsearch.Aggregations.AggregationDictionary? Aggregations { get; set; } + public Elastic.Clients.Elasticsearch.Field? Field { get; set; } public string? Format { get; set; } @@ -197,6 +216,12 @@ public RangeAggregationDescriptor() : base() { } + private Elastic.Clients.Elasticsearch.Aggregations.AggregationDictionary? AggregationsValue { get; set; } + + private Elastic.Clients.Elasticsearch.Aggregations.AggregationContainerDescriptor AggregationsDescriptor { get; set; } + + private Action> AggregationsDescriptorAction { get; set; } + private Elastic.Clients.Elasticsearch.Field? FieldValue { get; set; } private string? FormatValue { get; set; } @@ -215,6 +240,30 @@ public RangeAggregationDescriptor() : base() private Elastic.Clients.Elasticsearch.Script? ScriptValue { get; set; } + public RangeAggregationDescriptor Aggregations(Elastic.Clients.Elasticsearch.Aggregations.AggregationDictionary? aggregations) + { + AggregationsDescriptor = null; + AggregationsDescriptorAction = null; + AggregationsValue = aggregations; + return Self; + } + + public RangeAggregationDescriptor Aggregations(Elastic.Clients.Elasticsearch.Aggregations.AggregationContainerDescriptor descriptor) + { + AggregationsValue = null; + AggregationsDescriptorAction = null; + AggregationsDescriptor = descriptor; + return Self; + } + + public RangeAggregationDescriptor Aggregations(Action> configure) + { + AggregationsValue = null; + AggregationsDescriptor = null; + AggregationsDescriptorAction = configure; + return Self; + } + public RangeAggregationDescriptor Field(Elastic.Clients.Elasticsearch.Field? field) { FieldValue = field; @@ -354,6 +403,22 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o JsonSerializer.Serialize(writer, MetaValue, options); } + if (AggregationsDescriptor is not null) + { + writer.WritePropertyName("aggregations"); + JsonSerializer.Serialize(writer, AggregationsDescriptor, options); + } + else if (AggregationsDescriptorAction is not null) + { + writer.WritePropertyName("aggregations"); + JsonSerializer.Serialize(writer, new AggregationContainerDescriptor(AggregationsDescriptorAction), options); + } + else if (AggregationsValue is not null) + { + writer.WritePropertyName("aggregations"); + JsonSerializer.Serialize(writer, AggregationsValue, options); + } + writer.WriteEndObject(); } } @@ -365,6 +430,12 @@ public RangeAggregationDescriptor() : base() { } + private Elastic.Clients.Elasticsearch.Aggregations.AggregationDictionary? AggregationsValue { get; set; } + + private Elastic.Clients.Elasticsearch.Aggregations.AggregationContainerDescriptor AggregationsDescriptor { get; set; } + + private Action AggregationsDescriptorAction { get; set; } + private Elastic.Clients.Elasticsearch.Field? FieldValue { get; set; } private string? FormatValue { get; set; } @@ -383,6 +454,30 @@ public RangeAggregationDescriptor() : base() private Elastic.Clients.Elasticsearch.Script? ScriptValue { get; set; } + public RangeAggregationDescriptor Aggregations(Elastic.Clients.Elasticsearch.Aggregations.AggregationDictionary? aggregations) + { + AggregationsDescriptor = null; + AggregationsDescriptorAction = null; + AggregationsValue = aggregations; + return Self; + } + + public RangeAggregationDescriptor Aggregations(Elastic.Clients.Elasticsearch.Aggregations.AggregationContainerDescriptor descriptor) + { + AggregationsValue = null; + AggregationsDescriptorAction = null; + AggregationsDescriptor = descriptor; + return Self; + } + + public RangeAggregationDescriptor Aggregations(Action configure) + { + AggregationsValue = null; + AggregationsDescriptor = null; + AggregationsDescriptorAction = configure; + return Self; + } + public RangeAggregationDescriptor Field(Elastic.Clients.Elasticsearch.Field? field) { FieldValue = field; @@ -528,6 +623,22 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o JsonSerializer.Serialize(writer, MetaValue, options); } + if (AggregationsDescriptor is not null) + { + writer.WritePropertyName("aggregations"); + JsonSerializer.Serialize(writer, AggregationsDescriptor, options); + } + else if (AggregationsDescriptorAction is not null) + { + writer.WritePropertyName("aggregations"); + JsonSerializer.Serialize(writer, new AggregationContainerDescriptor(AggregationsDescriptorAction), options); + } + else if (AggregationsValue is not null) + { + writer.WritePropertyName("aggregations"); + JsonSerializer.Serialize(writer, AggregationsValue, options); + } + writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/ReverseNestedAggregation.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/ReverseNestedAggregation.g.cs index a99a8c93842..78d249f8b1e 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/ReverseNestedAggregation.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/ReverseNestedAggregation.g.cs @@ -67,6 +67,17 @@ public override ReverseNestedAggregation Read(ref Utf8JsonReader reader, Type ty continue; } + + if (reader.ValueTextEquals("aggs") || reader.ValueTextEquals("aggregations")) + { + var value = JsonSerializer.Deserialize(ref reader, options); + if (value is not null) + { + agg.Aggregations = value; + } + + continue; + } } } @@ -91,6 +102,12 @@ public override void Write(Utf8JsonWriter writer, ReverseNestedAggregation value JsonSerializer.Serialize(writer, value.Meta, options); } + if (value.Aggregations is not null) + { + writer.WritePropertyName("aggregations"); + JsonSerializer.Serialize(writer, value.Aggregations, options); + } + writer.WriteEndObject(); } } @@ -103,6 +120,8 @@ internal ReverseNestedAggregation() { } + public Elastic.Clients.Elasticsearch.Aggregations.AggregationDictionary? Aggregations { get; set; } + public Dictionary? Meta { get; set; } public override string? Name { get; internal set; } @@ -117,10 +136,40 @@ public ReverseNestedAggregationDescriptor() : base() { } + private Elastic.Clients.Elasticsearch.Aggregations.AggregationDictionary? AggregationsValue { get; set; } + + private Elastic.Clients.Elasticsearch.Aggregations.AggregationContainerDescriptor AggregationsDescriptor { get; set; } + + private Action> AggregationsDescriptorAction { get; set; } + private Dictionary? MetaValue { get; set; } private Elastic.Clients.Elasticsearch.Field? PathValue { get; set; } + public ReverseNestedAggregationDescriptor Aggregations(Elastic.Clients.Elasticsearch.Aggregations.AggregationDictionary? aggregations) + { + AggregationsDescriptor = null; + AggregationsDescriptorAction = null; + AggregationsValue = aggregations; + return Self; + } + + public ReverseNestedAggregationDescriptor Aggregations(Elastic.Clients.Elasticsearch.Aggregations.AggregationContainerDescriptor descriptor) + { + AggregationsValue = null; + AggregationsDescriptorAction = null; + AggregationsDescriptor = descriptor; + return Self; + } + + public ReverseNestedAggregationDescriptor Aggregations(Action> configure) + { + AggregationsValue = null; + AggregationsDescriptor = null; + AggregationsDescriptorAction = configure; + return Self; + } + public ReverseNestedAggregationDescriptor Meta(Func, FluentDictionary> selector) { MetaValue = selector?.Invoke(new FluentDictionary()); @@ -157,6 +206,22 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o JsonSerializer.Serialize(writer, MetaValue, options); } + if (AggregationsDescriptor is not null) + { + writer.WritePropertyName("aggregations"); + JsonSerializer.Serialize(writer, AggregationsDescriptor, options); + } + else if (AggregationsDescriptorAction is not null) + { + writer.WritePropertyName("aggregations"); + JsonSerializer.Serialize(writer, new AggregationContainerDescriptor(AggregationsDescriptorAction), options); + } + else if (AggregationsValue is not null) + { + writer.WritePropertyName("aggregations"); + JsonSerializer.Serialize(writer, AggregationsValue, options); + } + writer.WriteEndObject(); } } @@ -168,10 +233,40 @@ public ReverseNestedAggregationDescriptor() : base() { } + private Elastic.Clients.Elasticsearch.Aggregations.AggregationDictionary? AggregationsValue { get; set; } + + private Elastic.Clients.Elasticsearch.Aggregations.AggregationContainerDescriptor AggregationsDescriptor { get; set; } + + private Action AggregationsDescriptorAction { get; set; } + private Dictionary? MetaValue { get; set; } private Elastic.Clients.Elasticsearch.Field? PathValue { get; set; } + public ReverseNestedAggregationDescriptor Aggregations(Elastic.Clients.Elasticsearch.Aggregations.AggregationDictionary? aggregations) + { + AggregationsDescriptor = null; + AggregationsDescriptorAction = null; + AggregationsValue = aggregations; + return Self; + } + + public ReverseNestedAggregationDescriptor Aggregations(Elastic.Clients.Elasticsearch.Aggregations.AggregationContainerDescriptor descriptor) + { + AggregationsValue = null; + AggregationsDescriptorAction = null; + AggregationsDescriptor = descriptor; + return Self; + } + + public ReverseNestedAggregationDescriptor Aggregations(Action configure) + { + AggregationsValue = null; + AggregationsDescriptor = null; + AggregationsDescriptorAction = configure; + return Self; + } + public ReverseNestedAggregationDescriptor Meta(Func, FluentDictionary> selector) { MetaValue = selector?.Invoke(new FluentDictionary()); @@ -214,6 +309,22 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o JsonSerializer.Serialize(writer, MetaValue, options); } + if (AggregationsDescriptor is not null) + { + writer.WritePropertyName("aggregations"); + JsonSerializer.Serialize(writer, AggregationsDescriptor, options); + } + else if (AggregationsDescriptorAction is not null) + { + writer.WritePropertyName("aggregations"); + JsonSerializer.Serialize(writer, new AggregationContainerDescriptor(AggregationsDescriptorAction), options); + } + else if (AggregationsValue is not null) + { + writer.WritePropertyName("aggregations"); + JsonSerializer.Serialize(writer, AggregationsValue, options); + } + writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/SamplerAggregation.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/SamplerAggregation.g.cs index 82adeca8168..c4c743a965e 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/SamplerAggregation.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/SamplerAggregation.g.cs @@ -67,6 +67,17 @@ public override SamplerAggregation Read(ref Utf8JsonReader reader, Type typeToCo continue; } + + if (reader.ValueTextEquals("aggs") || reader.ValueTextEquals("aggregations")) + { + var value = JsonSerializer.Deserialize(ref reader, options); + if (value is not null) + { + agg.Aggregations = value; + } + + continue; + } } } @@ -91,6 +102,12 @@ public override void Write(Utf8JsonWriter writer, SamplerAggregation value, Json JsonSerializer.Serialize(writer, value.Meta, options); } + if (value.Aggregations is not null) + { + writer.WritePropertyName("aggregations"); + JsonSerializer.Serialize(writer, value.Aggregations, options); + } + writer.WriteEndObject(); } } @@ -103,6 +120,8 @@ internal SamplerAggregation() { } + public Elastic.Clients.Elasticsearch.Aggregations.AggregationDictionary? Aggregations { get; set; } + public Dictionary? Meta { get; set; } public override string? Name { get; internal set; } @@ -110,6 +129,97 @@ internal SamplerAggregation() public int? ShardSize { get; set; } } + public sealed partial class SamplerAggregationDescriptor : SerializableDescriptorBase> + { + internal SamplerAggregationDescriptor(Action> configure) => configure.Invoke(this); + public SamplerAggregationDescriptor() : base() + { + } + + private Elastic.Clients.Elasticsearch.Aggregations.AggregationDictionary? AggregationsValue { get; set; } + + private Elastic.Clients.Elasticsearch.Aggregations.AggregationContainerDescriptor AggregationsDescriptor { get; set; } + + private Action> AggregationsDescriptorAction { get; set; } + + private Dictionary? MetaValue { get; set; } + + private int? ShardSizeValue { get; set; } + + public SamplerAggregationDescriptor Aggregations(Elastic.Clients.Elasticsearch.Aggregations.AggregationDictionary? aggregations) + { + AggregationsDescriptor = null; + AggregationsDescriptorAction = null; + AggregationsValue = aggregations; + return Self; + } + + public SamplerAggregationDescriptor Aggregations(Elastic.Clients.Elasticsearch.Aggregations.AggregationContainerDescriptor descriptor) + { + AggregationsValue = null; + AggregationsDescriptorAction = null; + AggregationsDescriptor = descriptor; + return Self; + } + + public SamplerAggregationDescriptor Aggregations(Action> configure) + { + AggregationsValue = null; + AggregationsDescriptor = null; + AggregationsDescriptorAction = configure; + return Self; + } + + public SamplerAggregationDescriptor Meta(Func, FluentDictionary> selector) + { + MetaValue = selector?.Invoke(new FluentDictionary()); + return Self; + } + + public SamplerAggregationDescriptor ShardSize(int? shardSize) + { + ShardSizeValue = shardSize; + return Self; + } + + protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) + { + writer.WriteStartObject(); + writer.WritePropertyName("sampler"); + writer.WriteStartObject(); + if (ShardSizeValue.HasValue) + { + writer.WritePropertyName("shard_size"); + writer.WriteNumberValue(ShardSizeValue.Value); + } + + writer.WriteEndObject(); + if (MetaValue is not null) + { + writer.WritePropertyName("meta"); + JsonSerializer.Serialize(writer, MetaValue, options); + } + + if (AggregationsDescriptor is not null) + { + writer.WritePropertyName("aggregations"); + JsonSerializer.Serialize(writer, AggregationsDescriptor, options); + } + else if (AggregationsDescriptorAction is not null) + { + writer.WritePropertyName("aggregations"); + JsonSerializer.Serialize(writer, new AggregationContainerDescriptor(AggregationsDescriptorAction), options); + } + else if (AggregationsValue is not null) + { + writer.WritePropertyName("aggregations"); + JsonSerializer.Serialize(writer, AggregationsValue, options); + } + + writer.WriteEndObject(); + } + } + public sealed partial class SamplerAggregationDescriptor : SerializableDescriptorBase { internal SamplerAggregationDescriptor(Action configure) => configure.Invoke(this); @@ -117,10 +227,40 @@ public SamplerAggregationDescriptor() : base() { } + private Elastic.Clients.Elasticsearch.Aggregations.AggregationDictionary? AggregationsValue { get; set; } + + private Elastic.Clients.Elasticsearch.Aggregations.AggregationContainerDescriptor AggregationsDescriptor { get; set; } + + private Action AggregationsDescriptorAction { get; set; } + private Dictionary? MetaValue { get; set; } private int? ShardSizeValue { get; set; } + public SamplerAggregationDescriptor Aggregations(Elastic.Clients.Elasticsearch.Aggregations.AggregationDictionary? aggregations) + { + AggregationsDescriptor = null; + AggregationsDescriptorAction = null; + AggregationsValue = aggregations; + return Self; + } + + public SamplerAggregationDescriptor Aggregations(Elastic.Clients.Elasticsearch.Aggregations.AggregationContainerDescriptor descriptor) + { + AggregationsValue = null; + AggregationsDescriptorAction = null; + AggregationsDescriptor = descriptor; + return Self; + } + + public SamplerAggregationDescriptor Aggregations(Action configure) + { + AggregationsValue = null; + AggregationsDescriptor = null; + AggregationsDescriptorAction = configure; + return Self; + } + public SamplerAggregationDescriptor Meta(Func, FluentDictionary> selector) { MetaValue = selector?.Invoke(new FluentDictionary()); @@ -151,6 +291,22 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o JsonSerializer.Serialize(writer, MetaValue, options); } + if (AggregationsDescriptor is not null) + { + writer.WritePropertyName("aggregations"); + JsonSerializer.Serialize(writer, AggregationsDescriptor, options); + } + else if (AggregationsDescriptorAction is not null) + { + writer.WritePropertyName("aggregations"); + JsonSerializer.Serialize(writer, new AggregationContainerDescriptor(AggregationsDescriptorAction), options); + } + else if (AggregationsValue is not null) + { + writer.WritePropertyName("aggregations"); + JsonSerializer.Serialize(writer, AggregationsValue, options); + } + writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/TermsAggregation.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/TermsAggregation.g.cs index 55b2990e75f..5296e6fd822 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/TermsAggregation.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/TermsAggregation.g.cs @@ -235,6 +235,17 @@ public override TermsAggregation Read(ref Utf8JsonReader reader, Type typeToConv continue; } + + if (reader.ValueTextEquals("aggs") || reader.ValueTextEquals("aggregations")) + { + var value = JsonSerializer.Deserialize(ref reader, options); + if (value is not null) + { + agg.Aggregations = value; + } + + continue; + } } } @@ -343,6 +354,12 @@ public override void Write(Utf8JsonWriter writer, TermsAggregation value, JsonSe JsonSerializer.Serialize(writer, value.Meta, options); } + if (value.Aggregations is not null) + { + writer.WritePropertyName("aggregations"); + JsonSerializer.Serialize(writer, value.Aggregations, options); + } + writer.WriteEndObject(); } } @@ -355,6 +372,8 @@ internal TermsAggregation() { } + public Elastic.Clients.Elasticsearch.Aggregations.AggregationDictionary? Aggregations { get; set; } + public Elastic.Clients.Elasticsearch.Aggregations.TermsAggregationCollectMode? CollectMode { get; set; } [JsonConverter(typeof(TermsExcludeConverter))] @@ -399,6 +418,12 @@ public TermsAggregationDescriptor() : base() { } + private Elastic.Clients.Elasticsearch.Aggregations.AggregationDictionary? AggregationsValue { get; set; } + + private Elastic.Clients.Elasticsearch.Aggregations.AggregationContainerDescriptor AggregationsDescriptor { get; set; } + + private Action> AggregationsDescriptorAction { get; set; } + private Elastic.Clients.Elasticsearch.Aggregations.TermsAggregationCollectMode? CollectModeValue { get; set; } private IEnumerable? ExcludeValue { get; set; } @@ -431,6 +456,30 @@ public TermsAggregationDescriptor() : base() private string? ValueTypeValue { get; set; } + public TermsAggregationDescriptor Aggregations(Elastic.Clients.Elasticsearch.Aggregations.AggregationDictionary? aggregations) + { + AggregationsDescriptor = null; + AggregationsDescriptorAction = null; + AggregationsValue = aggregations; + return Self; + } + + public TermsAggregationDescriptor Aggregations(Elastic.Clients.Elasticsearch.Aggregations.AggregationContainerDescriptor descriptor) + { + AggregationsValue = null; + AggregationsDescriptorAction = null; + AggregationsDescriptor = descriptor; + return Self; + } + + public TermsAggregationDescriptor Aggregations(Action> configure) + { + AggregationsValue = null; + AggregationsDescriptor = null; + AggregationsDescriptorAction = configure; + return Self; + } + public TermsAggregationDescriptor CollectMode(Elastic.Clients.Elasticsearch.Aggregations.TermsAggregationCollectMode? collectMode) { CollectModeValue = collectMode; @@ -635,6 +684,22 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o JsonSerializer.Serialize(writer, MetaValue, options); } + if (AggregationsDescriptor is not null) + { + writer.WritePropertyName("aggregations"); + JsonSerializer.Serialize(writer, AggregationsDescriptor, options); + } + else if (AggregationsDescriptorAction is not null) + { + writer.WritePropertyName("aggregations"); + JsonSerializer.Serialize(writer, new AggregationContainerDescriptor(AggregationsDescriptorAction), options); + } + else if (AggregationsValue is not null) + { + writer.WritePropertyName("aggregations"); + JsonSerializer.Serialize(writer, AggregationsValue, options); + } + writer.WriteEndObject(); } } @@ -646,6 +711,12 @@ public TermsAggregationDescriptor() : base() { } + private Elastic.Clients.Elasticsearch.Aggregations.AggregationDictionary? AggregationsValue { get; set; } + + private Elastic.Clients.Elasticsearch.Aggregations.AggregationContainerDescriptor AggregationsDescriptor { get; set; } + + private Action AggregationsDescriptorAction { get; set; } + private Elastic.Clients.Elasticsearch.Aggregations.TermsAggregationCollectMode? CollectModeValue { get; set; } private IEnumerable? ExcludeValue { get; set; } @@ -678,6 +749,30 @@ public TermsAggregationDescriptor() : base() private string? ValueTypeValue { get; set; } + public TermsAggregationDescriptor Aggregations(Elastic.Clients.Elasticsearch.Aggregations.AggregationDictionary? aggregations) + { + AggregationsDescriptor = null; + AggregationsDescriptorAction = null; + AggregationsValue = aggregations; + return Self; + } + + public TermsAggregationDescriptor Aggregations(Elastic.Clients.Elasticsearch.Aggregations.AggregationContainerDescriptor descriptor) + { + AggregationsValue = null; + AggregationsDescriptorAction = null; + AggregationsDescriptor = descriptor; + return Self; + } + + public TermsAggregationDescriptor Aggregations(Action configure) + { + AggregationsValue = null; + AggregationsDescriptor = null; + AggregationsDescriptorAction = configure; + return Self; + } + public TermsAggregationDescriptor CollectMode(Elastic.Clients.Elasticsearch.Aggregations.TermsAggregationCollectMode? collectMode) { CollectModeValue = collectMode; @@ -888,6 +983,22 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o JsonSerializer.Serialize(writer, MetaValue, options); } + if (AggregationsDescriptor is not null) + { + writer.WritePropertyName("aggregations"); + JsonSerializer.Serialize(writer, AggregationsDescriptor, options); + } + else if (AggregationsDescriptorAction is not null) + { + writer.WritePropertyName("aggregations"); + JsonSerializer.Serialize(writer, new AggregationContainerDescriptor(AggregationsDescriptorAction), options); + } + else if (AggregationsValue is not null) + { + writer.WritePropertyName("aggregations"); + JsonSerializer.Serialize(writer, AggregationsValue, options); + } + writer.WriteEndObject(); } } diff --git a/tests/Tests/Aggregations/Bucket/DateHistogramAggregationUsageTests.cs b/tests/Tests/Aggregations/Bucket/DateHistogramAggregationUsageTests.cs index 431c16e3c32..4615120ef22 100644 --- a/tests/Tests/Aggregations/Bucket/DateHistogramAggregationUsageTests.cs +++ b/tests/Tests/Aggregations/Bucket/DateHistogramAggregationUsageTests.cs @@ -2,120 +2,120 @@ // 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; -//using System.Linq; -//using Elastic.Clients.Elasticsearch.Aggregations; -//using Tests.Core.Extensions; -//using Tests.Core.ManagedElasticsearch.Clusters; -//using Tests.Domain; -//using Tests.Framework.EndpointTests.TestState; -//using static Elastic.Clients.Elasticsearch.Infer; +using System; +using System.Linq; +using Elastic.Clients.Elasticsearch.Aggregations; +using Tests.Core.Extensions; +using Tests.Core.ManagedElasticsearch.Clusters; +using Tests.Domain; +using Tests.Framework.EndpointTests.TestState; +using static Elastic.Clients.Elasticsearch.Infer; -//namespace Tests.Aggregations.Bucket; +namespace Tests.Aggregations.Bucket; -//public class DateHistogramAggregationUsageTests : ProjectsOnlyAggregationUsageTestBase -//{ -// public DateHistogramAggregationUsageTests(ReadOnlyCluster i, EndpointUsage usage) : base(i, usage) { } +public class DateHistogramAggregationUsageTests : ProjectsOnlyAggregationUsageTestBase +{ + public DateHistogramAggregationUsageTests(ReadOnlyCluster i, EndpointUsage usage) : base(i, usage) { } -// protected override object AggregationJson => new -// { -// projects_started_per_month = new -// { -// date_histogram = new -// { -// field = "startedOn", -// calendar_interval = "month", -// min_doc_count = 2, -// format = "yyyy-MM-dd'T'HH:mm:ss||date_optional_time", // <1> Note the inclusion of `date_optional_time` to `format` -// order = new { _key = "asc" }, -// //extended_bounds = new -// //{ -// // min = FixedDate.AddYears(-1), -// // max = FixedDate.AddYears(1) -// //}, -// missing = "2015-06-06T12:01:02.123+00:00" -// }, -// aggregations = new -// { -// project_tags = new -// { -// nested = new -// { -// path = "tags" -// }, -// aggregations = new -// { -// tags = new -// { -// terms = new { field = "tags.name" } -// } -// } -// } -// } -// } -// }; + protected override object AggregationJson => new + { + projects_started_per_month = new + { + date_histogram = new + { + field = "startedOn", + calendar_interval = "month", + min_doc_count = 2, + format = "yyyy-MM-dd'T'HH:mm:ss||date_optional_time", // <1> Note the inclusion of `date_optional_time` to `format` + order = new { _key = "asc" }, + //extended_bounds = new + //{ + // min = FixedDate.AddYears(-1), + // max = FixedDate.AddYears(1) + //}, + missing = "2015-06-06T12:01:02.123+00:00" + }, + aggregations = new + { + project_tags = new + { + nested = new + { + path = "tags" + }, + aggregations = new + { + tags = new + { + terms = new { field = "tags.name" } + } + } + } + } + } + }; -// protected override Action> FluentAggs => a => a -// .DateHistogram("projects_started_per_month", date => date -// .Field(p => p.StartedOn) -// .CalendarInterval(CalendarInterval.Month) -// .MinDocCount(2) -// .Format("yyyy-MM-dd'T'HH:mm:ss||date_optional_time") -// //.ExtendedBounds(FixedDate.AddYears(-1), FixedDate.AddYears(1)) -// .Order(new[] { AggregateOrder.KeyAscending }) -// .Missing(DateTimeOffset.Parse("2015-06-06T12:01:02.1230000", styles: System.Globalization.DateTimeStyles.AssumeUniversal)) -// .Aggregations(childAggs => childAggs -// .Nested("project_tags", n => n -// .Path(p => p.Tags) -// .Aggregations(nestedAggs => nestedAggs -// .Terms("tags", avg => avg.Field(p => p.Tags.First().Name)) -// ) -// ) -// ) -// ); + protected override Action> FluentAggs => a => a + .DateHistogram("projects_started_per_month", date => date + .Field(p => p.StartedOn) + .CalendarInterval(CalendarInterval.Month) + .MinDocCount(2) + .Format("yyyy-MM-dd'T'HH:mm:ss||date_optional_time") + //.ExtendedBounds(FixedDate.AddYears(-1), FixedDate.AddYears(1)) + .Order(new[] { AggregateOrder.KeyAscending }) + .Missing(DateTimeOffset.Parse("2015-06-06T12:01:02.1230000", styles: System.Globalization.DateTimeStyles.AssumeUniversal)) + .Aggregations(childAggs => childAggs + .Nested("project_tags", n => n + .Path(p => p.Tags) + .Aggregations(nestedAggs => nestedAggs + .Terms("tags", avg => avg.Field(p => p.Tags.First().Name)) + ) + ) + ) + ); -// protected override AggregationDictionary InitializerAggs => -// new DateHistogramAggregation("projects_started_per_month") -// { -// Field = Field(p => p.StartedOn), -// CalendarInterval = CalendarInterval.Month, -// MinDocCount = 2, -// Format = "yyyy-MM-dd'T'HH:mm:ss||date_optional_time", -// //ExtendedBounds = new ExtendedBounds -// //{ -// // Minimum = FixedDate.AddYears(-1), -// // Maximum = FixedDate.AddYears(1), -// //}, -// Order = new[] { AggregateOrder.KeyAscending }, -// Missing = DateTimeOffset.Parse("2015-06-06T12:01:02.1230000", styles: System.Globalization.DateTimeStyles.AssumeUniversal), -// Aggregations = new NestedAggregation("project_tags") -// { -// Path = Field(p => p.Tags), -// Aggregations = new TermsAggregation("tags") -// { -// Field = Field(p => p.Tags.First().Name) -// } -// } -// }; + protected override AggregationDictionary InitializerAggs => + new DateHistogramAggregation("projects_started_per_month") + { + Field = Field(p => p.StartedOn), + CalendarInterval = CalendarInterval.Month, + MinDocCount = 2, + Format = "yyyy-MM-dd'T'HH:mm:ss||date_optional_time", + //ExtendedBounds = new ExtendedBounds + //{ + // Minimum = FixedDate.AddYears(-1), + // Maximum = FixedDate.AddYears(1), + //}, + Order = new[] { AggregateOrder.KeyAscending }, + Missing = DateTimeOffset.Parse("2015-06-06T12:01:02.1230000", styles: System.Globalization.DateTimeStyles.AssumeUniversal), + Aggregations = new NestedAggregation("project_tags") + { + Path = Field(p => p.Tags), + Aggregations = new TermsAggregation("tags") + { + Field = Field(p => p.Tags.First().Name) + } + } + }; -// protected override void ExpectResponse(SearchResponse response) -// { -// response.ShouldBeValid(); + protected override void ExpectResponse(SearchResponse response) + { + response.ShouldBeValid(); -// var dateHistogram = response.Aggregations.GetDateHistogram("projects_started_per_month"); -// dateHistogram.Should().NotBeNull(); -// //dateHistogram.Buckets.Should().NotBeNull(); -// //dateHistogram.Buckets.Count.Should().BeGreaterThan(10); -// //foreach (var item in dateHistogram.Buckets) -// //{ -// // item.Date.Should().NotBe(default(DateTime)); -// // item.DocCount.Should().BeGreaterThan(0); + var dateHistogram = response.Aggregations.GetDateHistogram("projects_started_per_month"); + dateHistogram.Should().NotBeNull(); + //dateHistogram.Buckets.Should().NotBeNull(); + //dateHistogram.Buckets.Count.Should().BeGreaterThan(10); + //foreach (var item in dateHistogram.Buckets) + //{ + // item.Date.Should().NotBe(default(DateTime)); + // item.DocCount.Should().BeGreaterThan(0); -// // var nested = item.Nested("project_tags"); -// // nested.Should().NotBeNull(); + // var nested = item.Nested("project_tags"); + // nested.Should().NotBeNull(); -// // var nestedTerms = nested.Terms("tags"); -// // nestedTerms.Buckets.Count.Should().BeGreaterThan(0); -// //} -// } -//} + // var nestedTerms = nested.Terms("tags"); + // nestedTerms.Buckets.Count.Should().BeGreaterThan(0); + //} + } +}