@@ -36,16 +36,21 @@ public interface IDateHistogramAggregation : IBucketAggregation
3636 [ JsonProperty ( "order" ) ]
3737 HistogramOrder Order { get ; set ; }
3838
39- [ JsonProperty ( "extended_bounds" ) ]
39+ [ JsonIgnore ]
40+ [ Obsolete ( "Use ExtendedBoundsDateMath that accepts DateMath expressions. Fixed in NEST 6.x" ) ]
4041 ExtendedBounds < DateTime > ExtendedBounds { get ; set ; }
4142
43+ [ JsonProperty ( "extended_bounds" ) ]
44+ ExtendedBounds < DateMath > ExtendedBoundsDateMath { get ; set ; }
45+
4246 [ JsonProperty ( "missing" ) ]
4347 DateTime ? Missing { get ; set ; }
4448 }
4549
4650 public class DateHistogramAggregation : BucketAggregationBase , IDateHistogramAggregation
4751 {
4852 private string _format ;
53+ private ExtendedBounds < DateTime > _extendedBounds ;
4954 public Field Field { get ; set ; }
5055 public IScript Script { get ; set ; }
5156 public IDictionary < string , object > Params { get ; set ; }
@@ -55,7 +60,7 @@ public string Format
5560 {
5661 get => ! string . IsNullOrEmpty ( _format ) &&
5762 ! _format . Contains ( "date_optional_time" ) &&
58- ( ExtendedBounds != null || Missing . HasValue )
63+ ( ExtendedBoundsDateMath != null || Missing . HasValue )
5964 ? _format + "||date_optional_time"
6065 : _format ;
6166 set => _format = value ;
@@ -65,7 +70,24 @@ public string Format
6570 public string TimeZone { get ; set ; }
6671 public string Offset { get ; set ; }
6772 public HistogramOrder Order { get ; set ; }
68- public ExtendedBounds < DateTime > ExtendedBounds { get ; set ; }
73+
74+ [ Obsolete ( "Use ExtendedBoundsDateMath that accepts DateMath expressions. Fixed in NEST 6.x" ) ]
75+ public ExtendedBounds < DateTime > ExtendedBounds
76+ {
77+ get => _extendedBounds ;
78+ set
79+ {
80+ _extendedBounds = value ;
81+ ExtendedBoundsDateMath = new ExtendedBounds < DateMath >
82+ {
83+ Minimum = value . Minimum ,
84+ Maximum = value . Maximum
85+ } ;
86+ }
87+ }
88+
89+ public ExtendedBounds < DateMath > ExtendedBoundsDateMath { get ; set ; }
90+
6991 public DateTime ? Missing { get ; set ; }
7092
7193 internal DateHistogramAggregation ( ) { }
@@ -81,6 +103,7 @@ public class DateHistogramAggregationDescriptor<T>
81103 where T : class
82104 {
83105 private string _format ;
106+ private ExtendedBounds < DateTime > _extendedBounds ;
84107 Field IDateHistogramAggregation . Field { get ; set ; }
85108
86109 IScript IDateHistogramAggregation . Script { get ; set ; }
@@ -93,7 +116,7 @@ string IDateHistogramAggregation.Format
93116 {
94117 get => ! string . IsNullOrEmpty ( _format ) &&
95118 ! _format . Contains ( "date_optional_time" ) &&
96- ( Self . ExtendedBounds != null || Self . Missing . HasValue )
119+ ( Self . ExtendedBoundsDateMath != null || Self . Missing . HasValue )
97120 ? _format + "||date_optional_time"
98121 : _format ;
99122 set => _format = value ;
@@ -107,7 +130,22 @@ string IDateHistogramAggregation.Format
107130
108131 HistogramOrder IDateHistogramAggregation . Order { get ; set ; }
109132
110- ExtendedBounds < DateTime > IDateHistogramAggregation . ExtendedBounds { get ; set ; }
133+ [ Obsolete ( "Use ExtendedBoundsDateMath that accepts DateMath expressions. Fixed in NEST 6.x" ) ]
134+ ExtendedBounds < DateTime > IDateHistogramAggregation . ExtendedBounds
135+ {
136+ get => _extendedBounds ;
137+ set
138+ {
139+ _extendedBounds = value ;
140+ Self . ExtendedBoundsDateMath = new ExtendedBounds < DateMath >
141+ {
142+ Minimum = value . Minimum ,
143+ Maximum = value . Maximum
144+ } ;
145+ }
146+ }
147+
148+ ExtendedBounds < DateMath > IDateHistogramAggregation . ExtendedBoundsDateMath { get ; set ; }
111149
112150 DateTime ? IDateHistogramAggregation . Missing { get ; set ; }
113151
@@ -142,9 +180,13 @@ public DateHistogramAggregationDescriptor<T> OrderAscending(string key) =>
142180 public DateHistogramAggregationDescriptor < T > OrderDescending ( string key ) =>
143181 Assign ( a => a . Order = new HistogramOrder { Key = key , Order = SortOrder . Descending } ) ;
144182
183+ [ Obsolete ( "Use ExtendedBoundsDateMath() that accepts DateMath expressions. Fixed in NEST 6.x" ) ]
145184 public DateHistogramAggregationDescriptor < T > ExtendedBounds ( DateTime min , DateTime max ) =>
146185 Assign ( a=> a . ExtendedBounds = new ExtendedBounds < DateTime > { Minimum = min , Maximum = max } ) ;
147186
187+ public DateHistogramAggregationDescriptor < T > ExtendedBoundsDateMath ( DateMath min , DateMath max ) =>
188+ Assign ( a=> a . ExtendedBoundsDateMath = new ExtendedBounds < DateMath > { Minimum = min , Maximum = max } ) ;
189+
148190 public DateHistogramAggregationDescriptor < T > Missing ( DateTime missing ) => Assign ( a => a . Missing = missing ) ;
149191 }
150192}
0 commit comments