From e53714fe7aac10fc60acbfe0dcf162aebb3454cf Mon Sep 17 00:00:00 2001 From: Laura Trotta <153528055+l-trotta@users.noreply.github.com> Date: Wed, 9 Apr 2025 16:05:09 +0200 Subject: [PATCH] reverting "making range aggregation untagged union (#2725)" (#4243) (cherry picked from commit bd62fe3fd9be090d197a570f459165a920a0240f) --- compiler/src/steps/validate-model.ts | 3 +- specification/_types/aggregations/bucket.ts | 61 +++++++++++---------- 2 files changed, 33 insertions(+), 31 deletions(-) diff --git a/compiler/src/steps/validate-model.ts b/compiler/src/steps/validate-model.ts index ad7ec1745b..272da3251b 100644 --- a/compiler/src/steps/validate-model.ts +++ b/compiler/src/steps/validate-model.ts @@ -597,8 +597,7 @@ export default async function validateModel (apiModel: model.Model, restSpec: Ma validateValueOf(valueOf, openGenerics) } else if (variants.kind === 'untagged') { - if (fqn(parentName) !== '_types.aggregations:AggregationRange' && - fqn(parentName) !== '_types.query_dsl:DecayFunction' && + if (fqn(parentName) !== '_types.query_dsl:DecayFunction' && fqn(parentName) !== '_types.query_dsl:DistanceFeatureQuery' && fqn(parentName) !== '_types.query_dsl:RangeQuery') { throw new Error(`Please contact the devtools team before adding new untagged variant ${fqn(parentName)}`) diff --git a/specification/_types/aggregations/bucket.ts b/specification/_types/aggregations/bucket.ts index 28ea96b3bc..88c6238ca9 100644 --- a/specification/_types/aggregations/bucket.ts +++ b/specification/_types/aggregations/bucket.ts @@ -295,7 +295,7 @@ export class DateRangeAggregation extends BucketAggregationBase { /** * Array of date ranges. */ - ranges?: DateAggregationRange[] + ranges?: DateRangeExpression[] /** * Time zone used to convert dates from another time zone to UTC. */ @@ -306,6 +306,33 @@ export class DateRangeAggregation extends BucketAggregationBase { keyed?: boolean } +/** + * A date range limit, represented either as a DateMath expression or a number expressed + * according to the target field's precision. + * + * @codegen_names expr, value + */ +// ES: DateRangeAggregationBuilder.innerBuild() +export type FieldDateMath = DateMath | double + +export class DateRangeExpression { + /** + * Start of the range (inclusive). + */ + from?: FieldDateMath + /** + * Custom key to return the range with. + */ + key?: string + /** + * End of the range (exclusive). + */ + to?: FieldDateMath +} + +/** + * @ext_doc_id search-aggregations-bucket-diversified-sampler-aggregation + */ export class DiversifiedSamplerAggregation extends BucketAggregationBase { /** * The type of value used for de-duplication. @@ -661,21 +688,11 @@ export class RangeAggregation extends BucketAggregationBase { format?: string } -/** - * @codegen_names untyped, date, number, term - * @variants untagged untyped=_types.aggregations.UntypedAggregationRange - */ -export type AggregationRange = - | UntypedAggregationRange - | DateAggregationRange - | NumberAggregationRange - | TermAggregationRange - -export class AggregationRangeBase { +export class AggregationRange { /** * Start of the range (inclusive). */ - from?: T + from?: double | null /** * Custom key to return the range with. */ @@ -683,26 +700,12 @@ export class AggregationRangeBase { /** * End of the range (exclusive). */ - to?: T + to?: double | null } -export class NumberAggregationRange extends AggregationRangeBase {} - -export class TermAggregationRange extends AggregationRangeBase {} - -export class UntypedAggregationRange extends AggregationRangeBase {} - -export class DateAggregationRange extends AggregationRangeBase {} - /** - * A date range limit, represented either as a DateMath expression or a number expressed - * according to the target field's precision. - * - * @codegen_names expr, value + * @ext_doc_id search-aggregations-bucket-rare-terms-aggregation */ -// ES: DateRangeAggregationBuilder.innerBuild() -export type FieldDateMath = DateMath | double - export class RareTermsAggregation extends BucketAggregationBase { /** * Terms that should be excluded from the aggregation.