From a958be1bb76adb21894a508d9d3372e4319da03d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Laurent=20Saint-F=C3=A9lix?= Date: Thu, 22 Jun 2023 12:03:03 +0200 Subject: [PATCH] fix composite aggregation, terms, histogram, date_histogram and geotile are not standard aggregations --- output/schema/schema.json | 347 ++++++++++++++++---- output/typescript/types.ts | 37 ++- specification/_types/aggregations/bucket.ts | 48 ++- 3 files changed, 362 insertions(+), 70 deletions(-) diff --git a/output/schema/schema.json b/output/schema/schema.json index ae4b03112e..fe996312ae 100644 --- a/output/schema/schema.json +++ b/output/schema/schema.json @@ -46820,7 +46820,7 @@ } } ], - "specLocation": "_types/aggregations/bucket.ts#L48-L54" + "specLocation": "_types/aggregations/bucket.ts#L56-L62" }, { "attachedBehaviors": [ @@ -47379,7 +47379,7 @@ "name": "AggregateOrder", "namespace": "_types.aggregations" }, - "specLocation": "_types/aggregations/bucket.ts#L566-L568", + "specLocation": "_types/aggregations/bucket.ts#L602-L604", "type": { "items": [ { @@ -48523,7 +48523,7 @@ } } ], - "specLocation": "_types/aggregations/bucket.ts#L461-L465" + "specLocation": "_types/aggregations/bucket.ts#L497-L501" }, { "kind": "interface", @@ -48745,7 +48745,7 @@ } } ], - "specLocation": "_types/aggregations/bucket.ts#L56-L91" + "specLocation": "_types/aggregations/bucket.ts#L64-L99" }, { "inherits": { @@ -49006,7 +49006,7 @@ "namespace": "_types.aggregations" }, "properties": [], - "specLocation": "_types/aggregations/bucket.ts#L41-L46" + "specLocation": "_types/aggregations/bucket.ts#L49-L54" }, { "description": "A sibling pipeline aggregation which executes a correlation function on the configured sibling multi-bucket aggregation.", @@ -49540,7 +49540,7 @@ "name": "CalendarInterval", "namespace": "_types.aggregations" }, - "specLocation": "_types/aggregations/bucket.ts#L208-L225" + "specLocation": "_types/aggregations/bucket.ts#L244-L261" }, { "inherits": { @@ -49794,7 +49794,7 @@ } } ], - "specLocation": "_types/aggregations/bucket.ts#L600-L664" + "specLocation": "_types/aggregations/bucket.ts#L636-L700" }, { "codegenNames": [ @@ -49806,7 +49806,7 @@ "name": "CategorizeTextAnalyzer", "namespace": "_types.aggregations" }, - "specLocation": "_types/aggregations/bucket.ts#L666-L669", + "specLocation": "_types/aggregations/bucket.ts#L702-L705", "type": { "items": [ { @@ -49857,7 +49857,7 @@ } } ], - "specLocation": "_types/aggregations/bucket.ts#L485-L488" + "specLocation": "_types/aggregations/bucket.ts#L521-L524" }, { "attachedBehaviors": [ @@ -49904,7 +49904,7 @@ } } ], - "specLocation": "_types/aggregations/bucket.ts#L102-L107" + "specLocation": "_types/aggregations/bucket.ts#L110-L115" }, { "inherits": { @@ -49949,7 +49949,7 @@ "name": "CompositeAggregateKey", "namespace": "_types.aggregations" }, - "specLocation": "_types/aggregations/bucket.ts#L109-L109", + "specLocation": "_types/aggregations/bucket.ts#L117-L117", "type": { "key": { "kind": "instance_of", @@ -50034,7 +50034,94 @@ } } ], - "specLocation": "_types/aggregations/bucket.ts#L111-L127" + "specLocation": "_types/aggregations/bucket.ts#L119-L135" + }, + { + "kind": "interface", + "name": { + "name": "CompositeAggregationBase", + "namespace": "_types.aggregations" + }, + "properties": [ + { + "name": "field", + "required": false, + "type": { + "kind": "instance_of", + "type": { + "name": "Field", + "namespace": "_types" + } + } + }, + { + "name": "missing", + "required": false, + "type": { + "kind": "instance_of", + "type": { + "name": "Missing", + "namespace": "_types.aggregations" + } + } + }, + { + "name": "missing_order", + "required": false, + "type": { + "kind": "instance_of", + "type": { + "name": "MissingOrder", + "namespace": "_types.aggregations" + } + } + }, + { + "name": "missing_bucket", + "required": false, + "type": { + "kind": "instance_of", + "type": { + "name": "boolean", + "namespace": "_builtins" + } + } + }, + { + "name": "script", + "required": false, + "type": { + "kind": "instance_of", + "type": { + "name": "Script", + "namespace": "_types" + } + } + }, + { + "name": "value_type", + "required": false, + "type": { + "kind": "instance_of", + "type": { + "name": "string", + "namespace": "_builtins" + } + } + }, + { + "name": "order", + "required": true, + "type": { + "kind": "instance_of", + "type": { + "name": "SortOrder", + "namespace": "_types" + } + } + } + ], + "specLocation": "_types/aggregations/bucket.ts#L156-L164" }, { "kind": "interface", @@ -50050,7 +50137,7 @@ "type": { "kind": "instance_of", "type": { - "name": "TermsAggregation", + "name": "CompositeTermsAggregation", "namespace": "_types.aggregations" } } @@ -50062,7 +50149,7 @@ "type": { "kind": "instance_of", "type": { - "name": "HistogramAggregation", + "name": "CompositeHistogramAggregation", "namespace": "_types.aggregations" } } @@ -50074,7 +50161,7 @@ "type": { "kind": "instance_of", "type": { - "name": "DateHistogramAggregation", + "name": "CompositeDateHistogramAggregation", "namespace": "_types.aggregations" } } @@ -50086,13 +50173,13 @@ "type": { "kind": "instance_of", "type": { - "name": "GeoTileGridAggregation", + "name": "CompositeGeoTileGridAggregation", "namespace": "_types.aggregations" } } } ], - "specLocation": "_types/aggregations/bucket.ts#L129-L146" + "specLocation": "_types/aggregations/bucket.ts#L137-L154" }, { "attachedBehaviors": [ @@ -50124,6 +50211,146 @@ ], "specLocation": "_types/aggregations/Aggregate.ts#L625-L627" }, + { + "inherits": { + "type": { + "name": "CompositeAggregationBase", + "namespace": "_types.aggregations" + } + }, + "kind": "interface", + "name": { + "name": "CompositeDateHistogramAggregation", + "namespace": "_types.aggregations" + }, + "properties": [ + { + "name": "format", + "required": true, + "type": { + "kind": "instance_of", + "type": { + "name": "string", + "namespace": "_builtins" + } + } + }, + { + "name": "calendar_interval", + "required": true, + "type": { + "kind": "instance_of", + "type": { + "name": "DurationLarge", + "namespace": "_types" + } + } + }, + { + "name": "offset", + "required": false, + "type": { + "kind": "instance_of", + "type": { + "name": "Duration", + "namespace": "_types" + } + } + }, + { + "name": "time_zone", + "required": false, + "type": { + "kind": "instance_of", + "type": { + "name": "TimeZone", + "namespace": "_types" + } + } + } + ], + "specLocation": "_types/aggregations/bucket.ts#L172-L177" + }, + { + "inherits": { + "type": { + "name": "CompositeAggregationBase", + "namespace": "_types.aggregations" + } + }, + "kind": "interface", + "name": { + "name": "CompositeGeoTileGridAggregation", + "namespace": "_types.aggregations" + }, + "properties": [ + { + "name": "precision", + "required": true, + "type": { + "kind": "instance_of", + "type": { + "name": "integer", + "namespace": "_types" + } + } + }, + { + "name": "bounds", + "required": false, + "type": { + "kind": "instance_of", + "type": { + "name": "GeoBounds", + "namespace": "_types" + } + } + } + ], + "specLocation": "_types/aggregations/bucket.ts#L179-L182" + }, + { + "inherits": { + "type": { + "name": "CompositeAggregationBase", + "namespace": "_types.aggregations" + } + }, + "kind": "interface", + "name": { + "name": "CompositeHistogramAggregation", + "namespace": "_types.aggregations" + }, + "properties": [ + { + "name": "interval", + "required": true, + "type": { + "kind": "instance_of", + "type": { + "name": "double", + "namespace": "_types" + } + } + } + ], + "specLocation": "_types/aggregations/bucket.ts#L168-L170" + }, + { + "inherits": { + "type": { + "name": "CompositeAggregationBase", + "namespace": "_types.aggregations" + } + }, + "kind": "interface", + "name": { + "name": "CompositeTermsAggregation", + "namespace": "_types.aggregations" + }, + "properties": [], + "specLocation": "_types/aggregations/bucket.ts#L166-L166" + }, { "description": "Result of the `cumulative_cardinality` aggregation", "inherits": { @@ -50241,7 +50468,7 @@ } } ], - "specLocation": "_types/aggregations/bucket.ts#L671-L675" + "specLocation": "_types/aggregations/bucket.ts#L707-L711" }, { "inherits": { @@ -50488,7 +50715,7 @@ } } ], - "specLocation": "_types/aggregations/bucket.ts#L148-L206" + "specLocation": "_types/aggregations/bucket.ts#L184-L242" }, { "attachedBehaviors": [ @@ -50646,7 +50873,7 @@ } } ], - "specLocation": "_types/aggregations/bucket.ts#L227-L253" + "specLocation": "_types/aggregations/bucket.ts#L263-L289" }, { "kind": "interface", @@ -50692,7 +50919,7 @@ } } ], - "specLocation": "_types/aggregations/bucket.ts#L264-L277" + "specLocation": "_types/aggregations/bucket.ts#L300-L313" }, { "inherits": { @@ -50824,7 +51051,7 @@ } } ], - "specLocation": "_types/aggregations/bucket.ts#L279-L300" + "specLocation": "_types/aggregations/bucket.ts#L315-L336" }, { "description": "Result of a `terms` aggregation when the field is some kind of decimal number like a float, double, or distance.", @@ -50985,7 +51212,7 @@ } } ], - "specLocation": "_types/aggregations/bucket.ts#L393-L396" + "specLocation": "_types/aggregations/bucket.ts#L429-L432" }, { "inherits": { @@ -51325,7 +51552,7 @@ "name": "FieldDateMath", "namespace": "_types.aggregations" }, - "specLocation": "_types/aggregations/bucket.ts#L255-L262", + "specLocation": "_types/aggregations/bucket.ts#L291-L298", "type": { "items": [ { @@ -51463,7 +51690,7 @@ } } ], - "specLocation": "_types/aggregations/bucket.ts#L317-L337" + "specLocation": "_types/aggregations/bucket.ts#L353-L373" }, { "attachedBehaviors": [ @@ -51636,7 +51863,7 @@ } } ], - "specLocation": "_types/aggregations/bucket.ts#L722-L746" + "specLocation": "_types/aggregations/bucket.ts#L758-L782" }, { "attachedBehaviors": [ @@ -51766,7 +51993,7 @@ } } ], - "specLocation": "_types/aggregations/bucket.ts#L708-L720" + "specLocation": "_types/aggregations/bucket.ts#L744-L756" }, { "kind": "enum", @@ -52011,7 +52238,7 @@ } } ], - "specLocation": "_types/aggregations/bucket.ts#L339-L345" + "specLocation": "_types/aggregations/bucket.ts#L375-L381" }, { "inherits": { @@ -52107,7 +52334,7 @@ } } ], - "specLocation": "_types/aggregations/bucket.ts#L347-L353" + "specLocation": "_types/aggregations/bucket.ts#L383-L389" }, { "attachedBehaviors": [ @@ -52441,7 +52668,7 @@ } } ], - "specLocation": "_types/aggregations/bucket.ts#L355-L361" + "specLocation": "_types/aggregations/bucket.ts#L391-L397" }, { "attachedBehaviors": [ @@ -52549,7 +52776,7 @@ } } ], - "specLocation": "_types/aggregations/bucket.ts#L363-L389" + "specLocation": "_types/aggregations/bucket.ts#L399-L425" }, { "attachedBehaviors": [ @@ -52583,7 +52810,7 @@ "namespace": "_types.aggregations" }, "properties": [], - "specLocation": "_types/aggregations/bucket.ts#L391-L391" + "specLocation": "_types/aggregations/bucket.ts#L427-L427" }, { "kind": "interface", @@ -52604,7 +52831,7 @@ } } ], - "specLocation": "_types/aggregations/bucket.ts#L490-L492" + "specLocation": "_types/aggregations/bucket.ts#L526-L528" }, { "kind": "interface", @@ -52837,7 +53064,7 @@ } } ], - "specLocation": "_types/aggregations/bucket.ts#L398-L410" + "specLocation": "_types/aggregations/bucket.ts#L434-L446" }, { "attachedBehaviors": [ @@ -53476,7 +53703,7 @@ } } ], - "specLocation": "_types/aggregations/bucket.ts#L677-L706" + "specLocation": "_types/aggregations/bucket.ts#L713-L742" }, { "attachedBehaviors": [ @@ -53605,7 +53832,7 @@ } } ], - "specLocation": "_types/aggregations/bucket.ts#L412-L415" + "specLocation": "_types/aggregations/bucket.ts#L448-L451" }, { "kind": "interface", @@ -53672,7 +53899,7 @@ } } ], - "specLocation": "_types/aggregations/bucket.ts#L417-L421" + "specLocation": "_types/aggregations/bucket.ts#L453-L457" }, { "attachedBehaviors": [ @@ -54384,7 +54611,7 @@ "name": "MinimumInterval", "namespace": "_types.aggregations" }, - "specLocation": "_types/aggregations/bucket.ts#L93-L100" + "specLocation": "_types/aggregations/bucket.ts#L101-L108" }, { "kind": "type_alias", @@ -54482,7 +54709,7 @@ } } ], - "specLocation": "_types/aggregations/bucket.ts#L423-L426" + "specLocation": "_types/aggregations/bucket.ts#L459-L462" }, { "kind": "enum", @@ -54823,7 +55050,7 @@ } } ], - "specLocation": "_types/aggregations/bucket.ts#L439-L442" + "specLocation": "_types/aggregations/bucket.ts#L475-L478" }, { "inherits": { @@ -54955,7 +55182,7 @@ } } ], - "specLocation": "_types/aggregations/bucket.ts#L428-L437" + "specLocation": "_types/aggregations/bucket.ts#L464-L473" }, { "attachedBehaviors": [ @@ -55042,7 +55269,7 @@ } } ], - "specLocation": "_types/aggregations/bucket.ts#L494-L497" + "specLocation": "_types/aggregations/bucket.ts#L530-L533" }, { "attachedBehaviors": [ @@ -55088,7 +55315,7 @@ } } ], - "specLocation": "_types/aggregations/bucket.ts#L444-L446" + "specLocation": "_types/aggregations/bucket.ts#L480-L482" }, { "inherits": { @@ -55190,7 +55417,7 @@ } } ], - "specLocation": "_types/aggregations/bucket.ts#L448-L450" + "specLocation": "_types/aggregations/bucket.ts#L484-L486" }, { "kind": "interface", @@ -55199,7 +55426,7 @@ "namespace": "_types.aggregations" }, "properties": [], - "specLocation": "_types/aggregations/bucket.ts#L499-L499" + "specLocation": "_types/aggregations/bucket.ts#L535-L535" }, { "inherits": { @@ -55597,7 +55824,7 @@ } } ], - "specLocation": "_types/aggregations/bucket.ts#L452-L459" + "specLocation": "_types/aggregations/bucket.ts#L488-L495" }, { "attachedBehaviors": [ @@ -55765,7 +55992,7 @@ } } ], - "specLocation": "_types/aggregations/bucket.ts#L467-L475" + "specLocation": "_types/aggregations/bucket.ts#L503-L511" }, { "inherits": { @@ -55904,7 +56131,7 @@ } } ], - "specLocation": "_types/aggregations/bucket.ts#L477-L479" + "specLocation": "_types/aggregations/bucket.ts#L513-L515" }, { "attachedBehaviors": [ @@ -55950,7 +56177,7 @@ } } ], - "specLocation": "_types/aggregations/bucket.ts#L481-L483" + "specLocation": "_types/aggregations/bucket.ts#L517-L519" }, { "kind": "enum", @@ -55972,7 +56199,7 @@ "name": "SamplerAggregationExecutionHint", "namespace": "_types.aggregations" }, - "specLocation": "_types/aggregations/bucket.ts#L302-L315" + "specLocation": "_types/aggregations/bucket.ts#L338-L351" }, { "kind": "interface", @@ -55993,7 +56220,7 @@ } } ], - "specLocation": "_types/aggregations/bucket.ts#L501-L503" + "specLocation": "_types/aggregations/bucket.ts#L537-L539" }, { "inherits": { @@ -56477,7 +56704,7 @@ } } ], - "specLocation": "_types/aggregations/bucket.ts#L505-L521" + "specLocation": "_types/aggregations/bucket.ts#L541-L557" }, { "attachedBehaviors": [ @@ -56736,7 +56963,7 @@ } } ], - "specLocation": "_types/aggregations/bucket.ts#L523-L541" + "specLocation": "_types/aggregations/bucket.ts#L559-L577" }, { "inherits": { @@ -58106,7 +58333,7 @@ } } ], - "specLocation": "_types/aggregations/bucket.ts#L543-L560" + "specLocation": "_types/aggregations/bucket.ts#L579-L596" }, { "kind": "enum", @@ -58122,7 +58349,7 @@ "name": "TermsAggregationCollectMode", "namespace": "_types.aggregations" }, - "specLocation": "_types/aggregations/bucket.ts#L570-L573" + "specLocation": "_types/aggregations/bucket.ts#L606-L609" }, { "kind": "enum", @@ -58144,7 +58371,7 @@ "name": "TermsAggregationExecutionHint", "namespace": "_types.aggregations" }, - "specLocation": "_types/aggregations/bucket.ts#L575-L580" + "specLocation": "_types/aggregations/bucket.ts#L611-L616" }, { "attachedBehaviors": [ @@ -58186,7 +58413,7 @@ "name": "TermsExclude", "namespace": "_types.aggregations" }, - "specLocation": "_types/aggregations/bucket.ts#L585-L586", + "specLocation": "_types/aggregations/bucket.ts#L621-L622", "type": { "items": [ { @@ -58221,7 +58448,7 @@ "name": "TermsInclude", "namespace": "_types.aggregations" }, - "specLocation": "_types/aggregations/bucket.ts#L582-L583", + "specLocation": "_types/aggregations/bucket.ts#L618-L619", "type": { "items": [ { @@ -58282,7 +58509,7 @@ } } ], - "specLocation": "_types/aggregations/bucket.ts#L588-L591" + "specLocation": "_types/aggregations/bucket.ts#L624-L627" }, { "kind": "interface", @@ -58951,7 +59178,7 @@ } } ], - "specLocation": "_types/aggregations/bucket.ts#L593-L598" + "specLocation": "_types/aggregations/bucket.ts#L629-L634" }, { "attachedBehaviors": [ diff --git a/output/typescript/types.ts b/output/typescript/types.ts index 324160725b..2d54edd718 100644 --- a/output/typescript/types.ts +++ b/output/typescript/types.ts @@ -3069,11 +3069,21 @@ export interface AggregationsCompositeAggregation extends AggregationsBucketAggr sources?: Record[] } +export interface AggregationsCompositeAggregationBase { + field?: Field + missing?: AggregationsMissing + missing_order?: AggregationsMissingOrder + missing_bucket?: boolean + script?: Script + value_type?: string + order: SortOrder +} + export interface AggregationsCompositeAggregationSource { - terms?: AggregationsTermsAggregation - histogram?: AggregationsHistogramAggregation - date_histogram?: AggregationsDateHistogramAggregation - geotile_grid?: AggregationsGeoTileGridAggregation + terms?: AggregationsCompositeTermsAggregation + histogram?: AggregationsCompositeHistogramAggregation + date_histogram?: AggregationsCompositeDateHistogramAggregation + geotile_grid?: AggregationsCompositeGeoTileGridAggregation } export interface AggregationsCompositeBucketKeys extends AggregationsMultiBucketBase { @@ -3082,6 +3092,25 @@ export interface AggregationsCompositeBucketKeys extends AggregationsMultiBucket export type AggregationsCompositeBucket = AggregationsCompositeBucketKeys & { [property: string]: AggregationsAggregate | AggregationsCompositeAggregateKey | long } +export interface AggregationsCompositeDateHistogramAggregation extends AggregationsCompositeAggregationBase { + format: string + calendar_interval: DurationLarge + offset?: Duration + time_zone?: TimeZone +} + +export interface AggregationsCompositeGeoTileGridAggregation extends AggregationsCompositeAggregationBase { + precision: integer + bounds?: GeoBounds +} + +export interface AggregationsCompositeHistogramAggregation extends AggregationsCompositeAggregationBase { + interval: double +} + +export interface AggregationsCompositeTermsAggregation extends AggregationsCompositeAggregationBase { +} + export interface AggregationsCumulativeCardinalityAggregate extends AggregationsAggregateBase { value: long value_as_string?: string diff --git a/specification/_types/aggregations/bucket.ts b/specification/_types/aggregations/bucket.ts index c9c4e826d1..5eb34a6970 100644 --- a/specification/_types/aggregations/bucket.ts +++ b/specification/_types/aggregations/bucket.ts @@ -33,10 +33,18 @@ import { import { integer, float, long, double } from '@_types/Numeric' import { QueryContainer } from '@_types/query_dsl/abstractions' import { Script } from '@_types/Scripting' -import { DateTime, Duration, DateMath, TimeZone } from '@_types/Time' -import { Buckets } from './Aggregate' +import { + DateTime, + Duration, + DateMath, + TimeZone, + DurationLarge +} from '@_types/Time' +import { Buckets, TermsAggregateBase } from './Aggregate' import { Aggregation } from './Aggregation' import { Missing, MissingOrder } from './AggregationContainer' +import { OverloadOf } from '@spec_utils/behaviors' +import { Term } from '@global/termvectors/types' /** * Base type for bucket aggregations. These aggregations also accept sub-aggregations. @@ -130,19 +138,47 @@ export class CompositeAggregationSource { /** * A terms aggregation. */ - terms?: TermsAggregation + terms?: CompositeTermsAggregation /** * A histogram aggregation. */ - histogram?: HistogramAggregation + histogram?: CompositeHistogramAggregation /** * A date histogram aggregation. */ - date_histogram?: DateHistogramAggregation + date_histogram?: CompositeDateHistogramAggregation /** * A geotile grid aggregation. */ - geotile_grid?: GeoTileGridAggregation + geotile_grid?: CompositeGeoTileGridAggregation +} + +export class CompositeAggregationBase { + field?: Field + missing?: Missing + missing_order?: MissingOrder + missing_bucket?: boolean + script?: Script + value_type?: string + order: SortOrder +} + +export class CompositeTermsAggregation extends CompositeAggregationBase {} + +export class CompositeHistogramAggregation extends CompositeAggregationBase { + interval: double +} + +export class CompositeDateHistogramAggregation extends CompositeAggregationBase { + format: string + calendar_interval: DurationLarge + offset?: Duration + time_zone?: TimeZone +} + +export class CompositeGeoTileGridAggregation extends CompositeAggregationBase { + precision: integer + bounds?: GeoBounds } export class DateHistogramAggregation extends BucketAggregationBase {