Skip to content

Commit 7c4a988

Browse files
committed
Merge pull request #1133 from elasticsearch/feature/histogram-bounds
Add pre_offset and post_offset params to histogram agg
2 parents da93a39 + 3347c5e commit 7c4a988

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

src/Nest/DSL/Aggregations/HistogramAggregationDescriptor.cs

+23
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@ public interface IHistogramAggregator : IBucketAggregator
3030

3131
[JsonProperty("extended_bounds")]
3232
IDictionary<string, object> ExtendedBounds { get; set; }
33+
34+
[JsonProperty("pre_offset")]
35+
long? PreOffset { get; set; }
36+
37+
[JsonProperty("post_offset")]
38+
long? PostOffset { get; set; }
3339
}
3440

3541
public class HistogramAggregator : BucketAggregator, IHistogramAggregator
@@ -41,6 +47,8 @@ public class HistogramAggregator : BucketAggregator, IHistogramAggregator
4147
public int? MinimumDocumentCount { get; set; }
4248
public IDictionary<string, string> Order { get; set; }
4349
public IDictionary<string, object> ExtendedBounds { get; set; }
50+
public long? PreOffset { get; set; }
51+
public long? PostOffset { get; set; }
4452
}
4553

4654
public class HistogramAggregationDescriptor<T> : BucketAggregationBaseDescriptor<HistogramAggregationDescriptor<T>, T>, IHistogramAggregator
@@ -62,6 +70,10 @@ public class HistogramAggregationDescriptor<T> : BucketAggregationBaseDescriptor
6270

6371
IDictionary<string, object> IHistogramAggregator.ExtendedBounds { get; set; }
6472

73+
long? IHistogramAggregator.PreOffset { get; set; }
74+
75+
long? IHistogramAggregator.PostOffset { get; set; }
76+
6577
public HistogramAggregationDescriptor<T> Field(string field)
6678
{
6779
Self.Field = field;
@@ -116,5 +128,16 @@ public HistogramAggregationDescriptor<T> ExtendedBounds(double min, double max)
116128
return this;
117129
}
118130

131+
public HistogramAggregationDescriptor<T> PreOffset(long preOffset)
132+
{
133+
Self.PreOffset = preOffset;
134+
return this;
135+
}
136+
137+
public HistogramAggregationDescriptor<T> PostOffset(long postOffset)
138+
{
139+
Self.PostOffset = postOffset;
140+
return this;
141+
}
119142
}
120143
}

src/Tests/Nest.Tests.Integration/Aggregations/BucketAggregationTests.cs

+2
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ public void Histogram()
7474
.Histogram("bucket_agg", m => m
7575
.Field(p => p.IntValues)
7676
.Interval(10)
77+
.PreOffset(5)
78+
.PostOffset(5)
7779
)
7880

7981
)

0 commit comments

Comments
 (0)