Skip to content

Commit ab98383

Browse files
Merge pull request #336 from bahamoth/main
chore: Support for extended_bounds in Date Histogram Aggregation for elastic-ts
2 parents 391e099 + e9557e4 commit ab98383

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed

src/types/aggregations.ts

+4
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,10 @@ export interface DateHistogramAggregation {
191191
fixed_interval?: string
192192
offset?: string
193193
min_doc_count?: number
194+
extended_bounds?: {
195+
min: number | string
196+
max: number | string
197+
}
194198
format?: string
195199
time_zone?: string
196200
keyed?: boolean

test/aggregations.spec.ts

+38
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,44 @@ describe('esBuilder - Aggregations', () => {
284284
})
285285
})
286286

287+
it('date_histogram aggregation with extended_bounds support', () => {
288+
const result = esBuilder().aggregation('agg_date_histogram_extended_bounds',
289+
'date_histogram', 'extended', { extended_bounds: {min: 0, max: 1} }).build()
290+
291+
expect(result).toEqual({
292+
aggs: {
293+
agg_date_histogram_extended_bounds: {
294+
date_histogram: {
295+
field: 'extended',
296+
extended_bounds: {
297+
max: 1,
298+
min: 0
299+
}
300+
},
301+
},
302+
},
303+
})
304+
})
305+
306+
it('date_histogram aggregation with extended_bounds support, date string format', () => {
307+
const result = esBuilder().aggregation('agg_date_histogram_extended_bounds',
308+
'date_histogram', 'extended', { extended_bounds: {min: '2024-01-01', max: '2024-12-31'} }).build()
309+
310+
expect(result).toEqual({
311+
aggs: {
312+
agg_date_histogram_extended_bounds: {
313+
date_histogram: {
314+
field: 'extended',
315+
extended_bounds: {
316+
max: '2024-12-31',
317+
min: '2024-01-01'
318+
}
319+
},
320+
},
321+
},
322+
})
323+
})
324+
287325
it('date_range aggregation', () => {
288326
const result = esBuilder()
289327
.aggregation('agg_date_range_date', 'date_range', 'date', {

0 commit comments

Comments
 (0)