Skip to content

Commit b30048e

Browse files
Implement extended_bounds and hard_bounds for {Date}HistogramAggregation (#8140) (#8142)
Co-authored-by: Florian Bernd <[email protected]>
1 parent 872aa5e commit b30048e

File tree

8 files changed

+1148
-0
lines changed

8 files changed

+1148
-0
lines changed

src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/DateHistogramAggregation.g.cs

+196
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@ public sealed partial class DateHistogramAggregation
3535
[JsonInclude, JsonPropertyName("calendar_interval")]
3636
public Elastic.Clients.Elasticsearch.Serverless.Aggregations.CalendarInterval? CalendarInterval { get; set; }
3737

38+
/// <summary>
39+
/// <para>Enables extending the bounds of the histogram beyond the data itself.</para>
40+
/// </summary>
41+
[JsonInclude, JsonPropertyName("extended_bounds")]
42+
public Elastic.Clients.Elasticsearch.Serverless.Aggregations.ExtendedBoundsDate? ExtendedBounds { get; set; }
43+
3844
/// <summary>
3945
/// <para>The date field whose values are use to build a histogram.</para>
4046
/// </summary>
@@ -53,6 +59,12 @@ public sealed partial class DateHistogramAggregation
5359
[JsonInclude, JsonPropertyName("format")]
5460
public string? Format { get; set; }
5561

62+
/// <summary>
63+
/// <para>Limits the histogram to specified bounds.</para>
64+
/// </summary>
65+
[JsonInclude, JsonPropertyName("hard_bounds")]
66+
public Elastic.Clients.Elasticsearch.Serverless.Aggregations.ExtendedBoundsDate? HardBounds { get; set; }
67+
5668
/// <summary>
5769
/// <para>Only returns buckets that have `min_doc_count` number of documents.<br/>By default, all buckets between the first bucket that matches documents and the last one are returned.</para>
5870
/// </summary>
@@ -101,9 +113,15 @@ public DateHistogramAggregationDescriptor() : base()
101113
}
102114

103115
private Elastic.Clients.Elasticsearch.Serverless.Aggregations.CalendarInterval? CalendarIntervalValue { get; set; }
116+
private Elastic.Clients.Elasticsearch.Serverless.Aggregations.ExtendedBoundsDate? ExtendedBoundsValue { get; set; }
117+
private Elastic.Clients.Elasticsearch.Serverless.Aggregations.ExtendedBoundsDateDescriptor ExtendedBoundsDescriptor { get; set; }
118+
private Action<Elastic.Clients.Elasticsearch.Serverless.Aggregations.ExtendedBoundsDateDescriptor> ExtendedBoundsDescriptorAction { get; set; }
104119
private Elastic.Clients.Elasticsearch.Serverless.Field? FieldValue { get; set; }
105120
private Elastic.Clients.Elasticsearch.Serverless.Duration? FixedIntervalValue { get; set; }
106121
private string? FormatValue { get; set; }
122+
private Elastic.Clients.Elasticsearch.Serverless.Aggregations.ExtendedBoundsDate? HardBoundsValue { get; set; }
123+
private Elastic.Clients.Elasticsearch.Serverless.Aggregations.ExtendedBoundsDateDescriptor HardBoundsDescriptor { get; set; }
124+
private Action<Elastic.Clients.Elasticsearch.Serverless.Aggregations.ExtendedBoundsDateDescriptor> HardBoundsDescriptorAction { get; set; }
107125
private int? MinDocCountValue { get; set; }
108126
private DateTimeOffset? MissingValue { get; set; }
109127
private Elastic.Clients.Elasticsearch.Serverless.Duration? OffsetValue { get; set; }
@@ -121,6 +139,33 @@ public DateHistogramAggregationDescriptor<TDocument> CalendarInterval(Elastic.Cl
121139
return Self;
122140
}
123141

142+
/// <summary>
143+
/// <para>Enables extending the bounds of the histogram beyond the data itself.</para>
144+
/// </summary>
145+
public DateHistogramAggregationDescriptor<TDocument> ExtendedBounds(Elastic.Clients.Elasticsearch.Serverless.Aggregations.ExtendedBoundsDate? extendedBounds)
146+
{
147+
ExtendedBoundsDescriptor = null;
148+
ExtendedBoundsDescriptorAction = null;
149+
ExtendedBoundsValue = extendedBounds;
150+
return Self;
151+
}
152+
153+
public DateHistogramAggregationDescriptor<TDocument> ExtendedBounds(Elastic.Clients.Elasticsearch.Serverless.Aggregations.ExtendedBoundsDateDescriptor descriptor)
154+
{
155+
ExtendedBoundsValue = null;
156+
ExtendedBoundsDescriptorAction = null;
157+
ExtendedBoundsDescriptor = descriptor;
158+
return Self;
159+
}
160+
161+
public DateHistogramAggregationDescriptor<TDocument> ExtendedBounds(Action<Elastic.Clients.Elasticsearch.Serverless.Aggregations.ExtendedBoundsDateDescriptor> configure)
162+
{
163+
ExtendedBoundsValue = null;
164+
ExtendedBoundsDescriptor = null;
165+
ExtendedBoundsDescriptorAction = configure;
166+
return Self;
167+
}
168+
124169
/// <summary>
125170
/// <para>The date field whose values are use to build a histogram.</para>
126171
/// </summary>
@@ -166,6 +211,33 @@ public DateHistogramAggregationDescriptor<TDocument> Format(string? format)
166211
return Self;
167212
}
168213

214+
/// <summary>
215+
/// <para>Limits the histogram to specified bounds.</para>
216+
/// </summary>
217+
public DateHistogramAggregationDescriptor<TDocument> HardBounds(Elastic.Clients.Elasticsearch.Serverless.Aggregations.ExtendedBoundsDate? hardBounds)
218+
{
219+
HardBoundsDescriptor = null;
220+
HardBoundsDescriptorAction = null;
221+
HardBoundsValue = hardBounds;
222+
return Self;
223+
}
224+
225+
public DateHistogramAggregationDescriptor<TDocument> HardBounds(Elastic.Clients.Elasticsearch.Serverless.Aggregations.ExtendedBoundsDateDescriptor descriptor)
226+
{
227+
HardBoundsValue = null;
228+
HardBoundsDescriptorAction = null;
229+
HardBoundsDescriptor = descriptor;
230+
return Self;
231+
}
232+
233+
public DateHistogramAggregationDescriptor<TDocument> HardBounds(Action<Elastic.Clients.Elasticsearch.Serverless.Aggregations.ExtendedBoundsDateDescriptor> configure)
234+
{
235+
HardBoundsValue = null;
236+
HardBoundsDescriptor = null;
237+
HardBoundsDescriptorAction = configure;
238+
return Self;
239+
}
240+
169241
/// <summary>
170242
/// <para>Only returns buckets that have `min_doc_count` number of documents.<br/>By default, all buckets between the first bucket that matches documents and the last one are returned.</para>
171243
/// </summary>
@@ -232,6 +304,22 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o
232304
JsonSerializer.Serialize(writer, CalendarIntervalValue, options);
233305
}
234306

307+
if (ExtendedBoundsDescriptor is not null)
308+
{
309+
writer.WritePropertyName("extended_bounds");
310+
JsonSerializer.Serialize(writer, ExtendedBoundsDescriptor, options);
311+
}
312+
else if (ExtendedBoundsDescriptorAction is not null)
313+
{
314+
writer.WritePropertyName("extended_bounds");
315+
JsonSerializer.Serialize(writer, new Elastic.Clients.Elasticsearch.Serverless.Aggregations.ExtendedBoundsDateDescriptor(ExtendedBoundsDescriptorAction), options);
316+
}
317+
else if (ExtendedBoundsValue is not null)
318+
{
319+
writer.WritePropertyName("extended_bounds");
320+
JsonSerializer.Serialize(writer, ExtendedBoundsValue, options);
321+
}
322+
235323
if (FieldValue is not null)
236324
{
237325
writer.WritePropertyName("field");
@@ -250,6 +338,22 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o
250338
writer.WriteStringValue(FormatValue);
251339
}
252340

341+
if (HardBoundsDescriptor is not null)
342+
{
343+
writer.WritePropertyName("hard_bounds");
344+
JsonSerializer.Serialize(writer, HardBoundsDescriptor, options);
345+
}
346+
else if (HardBoundsDescriptorAction is not null)
347+
{
348+
writer.WritePropertyName("hard_bounds");
349+
JsonSerializer.Serialize(writer, new Elastic.Clients.Elasticsearch.Serverless.Aggregations.ExtendedBoundsDateDescriptor(HardBoundsDescriptorAction), options);
350+
}
351+
else if (HardBoundsValue is not null)
352+
{
353+
writer.WritePropertyName("hard_bounds");
354+
JsonSerializer.Serialize(writer, HardBoundsValue, options);
355+
}
356+
253357
if (MinDocCountValue.HasValue)
254358
{
255359
writer.WritePropertyName("min_doc_count");
@@ -305,9 +409,15 @@ public DateHistogramAggregationDescriptor() : base()
305409
}
306410

307411
private Elastic.Clients.Elasticsearch.Serverless.Aggregations.CalendarInterval? CalendarIntervalValue { get; set; }
412+
private Elastic.Clients.Elasticsearch.Serverless.Aggregations.ExtendedBoundsDate? ExtendedBoundsValue { get; set; }
413+
private Elastic.Clients.Elasticsearch.Serverless.Aggregations.ExtendedBoundsDateDescriptor ExtendedBoundsDescriptor { get; set; }
414+
private Action<Elastic.Clients.Elasticsearch.Serverless.Aggregations.ExtendedBoundsDateDescriptor> ExtendedBoundsDescriptorAction { get; set; }
308415
private Elastic.Clients.Elasticsearch.Serverless.Field? FieldValue { get; set; }
309416
private Elastic.Clients.Elasticsearch.Serverless.Duration? FixedIntervalValue { get; set; }
310417
private string? FormatValue { get; set; }
418+
private Elastic.Clients.Elasticsearch.Serverless.Aggregations.ExtendedBoundsDate? HardBoundsValue { get; set; }
419+
private Elastic.Clients.Elasticsearch.Serverless.Aggregations.ExtendedBoundsDateDescriptor HardBoundsDescriptor { get; set; }
420+
private Action<Elastic.Clients.Elasticsearch.Serverless.Aggregations.ExtendedBoundsDateDescriptor> HardBoundsDescriptorAction { get; set; }
311421
private int? MinDocCountValue { get; set; }
312422
private DateTimeOffset? MissingValue { get; set; }
313423
private Elastic.Clients.Elasticsearch.Serverless.Duration? OffsetValue { get; set; }
@@ -325,6 +435,33 @@ public DateHistogramAggregationDescriptor CalendarInterval(Elastic.Clients.Elast
325435
return Self;
326436
}
327437

438+
/// <summary>
439+
/// <para>Enables extending the bounds of the histogram beyond the data itself.</para>
440+
/// </summary>
441+
public DateHistogramAggregationDescriptor ExtendedBounds(Elastic.Clients.Elasticsearch.Serverless.Aggregations.ExtendedBoundsDate? extendedBounds)
442+
{
443+
ExtendedBoundsDescriptor = null;
444+
ExtendedBoundsDescriptorAction = null;
445+
ExtendedBoundsValue = extendedBounds;
446+
return Self;
447+
}
448+
449+
public DateHistogramAggregationDescriptor ExtendedBounds(Elastic.Clients.Elasticsearch.Serverless.Aggregations.ExtendedBoundsDateDescriptor descriptor)
450+
{
451+
ExtendedBoundsValue = null;
452+
ExtendedBoundsDescriptorAction = null;
453+
ExtendedBoundsDescriptor = descriptor;
454+
return Self;
455+
}
456+
457+
public DateHistogramAggregationDescriptor ExtendedBounds(Action<Elastic.Clients.Elasticsearch.Serverless.Aggregations.ExtendedBoundsDateDescriptor> configure)
458+
{
459+
ExtendedBoundsValue = null;
460+
ExtendedBoundsDescriptor = null;
461+
ExtendedBoundsDescriptorAction = configure;
462+
return Self;
463+
}
464+
328465
/// <summary>
329466
/// <para>The date field whose values are use to build a histogram.</para>
330467
/// </summary>
@@ -370,6 +507,33 @@ public DateHistogramAggregationDescriptor Format(string? format)
370507
return Self;
371508
}
372509

510+
/// <summary>
511+
/// <para>Limits the histogram to specified bounds.</para>
512+
/// </summary>
513+
public DateHistogramAggregationDescriptor HardBounds(Elastic.Clients.Elasticsearch.Serverless.Aggregations.ExtendedBoundsDate? hardBounds)
514+
{
515+
HardBoundsDescriptor = null;
516+
HardBoundsDescriptorAction = null;
517+
HardBoundsValue = hardBounds;
518+
return Self;
519+
}
520+
521+
public DateHistogramAggregationDescriptor HardBounds(Elastic.Clients.Elasticsearch.Serverless.Aggregations.ExtendedBoundsDateDescriptor descriptor)
522+
{
523+
HardBoundsValue = null;
524+
HardBoundsDescriptorAction = null;
525+
HardBoundsDescriptor = descriptor;
526+
return Self;
527+
}
528+
529+
public DateHistogramAggregationDescriptor HardBounds(Action<Elastic.Clients.Elasticsearch.Serverless.Aggregations.ExtendedBoundsDateDescriptor> configure)
530+
{
531+
HardBoundsValue = null;
532+
HardBoundsDescriptor = null;
533+
HardBoundsDescriptorAction = configure;
534+
return Self;
535+
}
536+
373537
/// <summary>
374538
/// <para>Only returns buckets that have `min_doc_count` number of documents.<br/>By default, all buckets between the first bucket that matches documents and the last one are returned.</para>
375539
/// </summary>
@@ -436,6 +600,22 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o
436600
JsonSerializer.Serialize(writer, CalendarIntervalValue, options);
437601
}
438602

603+
if (ExtendedBoundsDescriptor is not null)
604+
{
605+
writer.WritePropertyName("extended_bounds");
606+
JsonSerializer.Serialize(writer, ExtendedBoundsDescriptor, options);
607+
}
608+
else if (ExtendedBoundsDescriptorAction is not null)
609+
{
610+
writer.WritePropertyName("extended_bounds");
611+
JsonSerializer.Serialize(writer, new Elastic.Clients.Elasticsearch.Serverless.Aggregations.ExtendedBoundsDateDescriptor(ExtendedBoundsDescriptorAction), options);
612+
}
613+
else if (ExtendedBoundsValue is not null)
614+
{
615+
writer.WritePropertyName("extended_bounds");
616+
JsonSerializer.Serialize(writer, ExtendedBoundsValue, options);
617+
}
618+
439619
if (FieldValue is not null)
440620
{
441621
writer.WritePropertyName("field");
@@ -454,6 +634,22 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o
454634
writer.WriteStringValue(FormatValue);
455635
}
456636

637+
if (HardBoundsDescriptor is not null)
638+
{
639+
writer.WritePropertyName("hard_bounds");
640+
JsonSerializer.Serialize(writer, HardBoundsDescriptor, options);
641+
}
642+
else if (HardBoundsDescriptorAction is not null)
643+
{
644+
writer.WritePropertyName("hard_bounds");
645+
JsonSerializer.Serialize(writer, new Elastic.Clients.Elasticsearch.Serverless.Aggregations.ExtendedBoundsDateDescriptor(HardBoundsDescriptorAction), options);
646+
}
647+
else if (HardBoundsValue is not null)
648+
{
649+
writer.WritePropertyName("hard_bounds");
650+
JsonSerializer.Serialize(writer, HardBoundsValue, options);
651+
}
652+
457653
if (MinDocCountValue.HasValue)
458654
{
459655
writer.WritePropertyName("min_doc_count");
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
// Licensed to Elasticsearch B.V under one or more agreements.
2+
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
3+
// See the LICENSE file in the project root for more information.
4+
//
5+
// ███╗ ██╗ ██████╗ ████████╗██╗ ██████╗███████╗
6+
// ████╗ ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝
7+
// ██╔██╗ ██║██║ ██║ ██║ ██║██║ █████╗
8+
// ██║╚██╗██║██║ ██║ ██║ ██║██║ ██╔══╝
9+
// ██║ ╚████║╚██████╔╝ ██║ ██║╚██████╗███████╗
10+
// ╚═╝ ╚═══╝ ╚═════╝ ╚═╝ ╚═╝ ╚═════╝╚══════╝
11+
// ------------------------------------------------
12+
//
13+
// This file is automatically generated.
14+
// Please do not edit these files manually.
15+
//
16+
// ------------------------------------------------
17+
18+
#nullable restore
19+
20+
using Elastic.Clients.Elasticsearch.Serverless.Fluent;
21+
using Elastic.Clients.Elasticsearch.Serverless.Serialization;
22+
using System;
23+
using System.Collections.Generic;
24+
using System.Linq.Expressions;
25+
using System.Text.Json;
26+
using System.Text.Json.Serialization;
27+
28+
namespace Elastic.Clients.Elasticsearch.Serverless.Aggregations;
29+
30+
public sealed partial class ExtendedBoundsDate
31+
{
32+
/// <summary>
33+
/// <para>Maximum value for the bound.</para>
34+
/// </summary>
35+
[JsonInclude, JsonPropertyName("max")]
36+
public Elastic.Clients.Elasticsearch.Serverless.Aggregations.FieldDateMath? Max { get; set; }
37+
38+
/// <summary>
39+
/// <para>Minimum value for the bound.</para>
40+
/// </summary>
41+
[JsonInclude, JsonPropertyName("min")]
42+
public Elastic.Clients.Elasticsearch.Serverless.Aggregations.FieldDateMath? Min { get; set; }
43+
}
44+
45+
public sealed partial class ExtendedBoundsDateDescriptor : SerializableDescriptor<ExtendedBoundsDateDescriptor>
46+
{
47+
internal ExtendedBoundsDateDescriptor(Action<ExtendedBoundsDateDescriptor> configure) => configure.Invoke(this);
48+
49+
public ExtendedBoundsDateDescriptor() : base()
50+
{
51+
}
52+
53+
private Elastic.Clients.Elasticsearch.Serverless.Aggregations.FieldDateMath? MaxValue { get; set; }
54+
private Elastic.Clients.Elasticsearch.Serverless.Aggregations.FieldDateMath? MinValue { get; set; }
55+
56+
/// <summary>
57+
/// <para>Maximum value for the bound.</para>
58+
/// </summary>
59+
public ExtendedBoundsDateDescriptor Max(Elastic.Clients.Elasticsearch.Serverless.Aggregations.FieldDateMath? max)
60+
{
61+
MaxValue = max;
62+
return Self;
63+
}
64+
65+
/// <summary>
66+
/// <para>Minimum value for the bound.</para>
67+
/// </summary>
68+
public ExtendedBoundsDateDescriptor Min(Elastic.Clients.Elasticsearch.Serverless.Aggregations.FieldDateMath? min)
69+
{
70+
MinValue = min;
71+
return Self;
72+
}
73+
74+
protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings)
75+
{
76+
writer.WriteStartObject();
77+
if (MaxValue is not null)
78+
{
79+
writer.WritePropertyName("max");
80+
JsonSerializer.Serialize(writer, MaxValue, options);
81+
}
82+
83+
if (MinValue is not null)
84+
{
85+
writer.WritePropertyName("min");
86+
JsonSerializer.Serialize(writer, MinValue, options);
87+
}
88+
89+
writer.WriteEndObject();
90+
}
91+
}

0 commit comments

Comments
 (0)