Skip to content

Commit ef8faf5

Browse files
committed
Date histogram agg descriptor now accepts DateInterval enum
Closes #981
1 parent c454cf6 commit ef8faf5

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

Diff for: src/Nest/DSL/Aggregations/DateHistogramAggregationDescriptor.cs

+7
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,13 @@ public DateHistogramAggregationDescriptor<T> Interval(string interval)
143143
Self.Interval = interval;
144144
return this;
145145
}
146+
147+
public DateHistogramAggregationDescriptor<T> Interval(DateInterval interval)
148+
{
149+
var intervalString = interval.GetStringValue();
150+
Self.Interval = intervalString;
151+
return this;
152+
}
146153

147154
public DateHistogramAggregationDescriptor<T> Format(string format)
148155
{

Diff for: src/Tests/Nest.Tests.Integration/Aggregations/BucketAggregationTests.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ public void DateHistogram()
232232
.Aggregations(a => a
233233
.DateHistogram("bucket_agg", dh => dh
234234
.Field(p => p.StartedOn)
235-
.Interval("1d")
235+
.Interval(DateInterval.Day)
236236
)
237237
)
238238
);

0 commit comments

Comments
 (0)