diff --git a/src/types/aggregations.ts b/src/types/aggregations.ts index 1b4cdaf..53411fe 100644 --- a/src/types/aggregations.ts +++ b/src/types/aggregations.ts @@ -191,6 +191,10 @@ export interface DateHistogramAggregation { fixed_interval?: string offset?: string min_doc_count?: number + extended_bounds?: { + min: number | string + max: number | string + } format?: string time_zone?: string keyed?: boolean diff --git a/test/aggregations.spec.ts b/test/aggregations.spec.ts index 93fff30..911700f 100644 --- a/test/aggregations.spec.ts +++ b/test/aggregations.spec.ts @@ -284,6 +284,44 @@ describe('esBuilder - Aggregations', () => { }) }) + it('date_histogram aggregation with extended_bounds support', () => { + const result = esBuilder().aggregation('agg_date_histogram_extended_bounds', + 'date_histogram', 'extended', { extended_bounds: {min: 0, max: 1} }).build() + + expect(result).toEqual({ + aggs: { + agg_date_histogram_extended_bounds: { + date_histogram: { + field: 'extended', + extended_bounds: { + max: 1, + min: 0 + } + }, + }, + }, + }) + }) + + it('date_histogram aggregation with extended_bounds support, date string format', () => { + const result = esBuilder().aggregation('agg_date_histogram_extended_bounds', + 'date_histogram', 'extended', { extended_bounds: {min: '2024-01-01', max: '2024-12-31'} }).build() + + expect(result).toEqual({ + aggs: { + agg_date_histogram_extended_bounds: { + date_histogram: { + field: 'extended', + extended_bounds: { + max: '2024-12-31', + min: '2024-01-01' + } + }, + }, + }, + }) + }) + it('date_range aggregation', () => { const result = esBuilder() .aggregation('agg_date_range_date', 'date_range', 'date', {