Skip to content

Commit

Permalink
Merge pull request #336 from bahamoth/main
Browse files Browse the repository at this point in the history
chore: Support for extended_bounds in Date Histogram Aggregation for elastic-ts
  • Loading branch information
jacobwgillespie authored Jan 23, 2024
2 parents 391e099 + e9557e4 commit ab98383
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/types/aggregations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
38 changes: 38 additions & 0 deletions test/aggregations.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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', {
Expand Down

0 comments on commit ab98383

Please sign in to comment.