Skip to content

Commit 617466c

Browse files
l-trottapquentin
andauthored
[Backport 8.19] Add cartesian_bounds, cartesian_centroid and change_point aggregations (#5439)
* Add cartesian_bounds, cartesian_centroid and change_point aggregations (#5418) (#5436) * fix search validation * add variants to changetype * Update specification/_types/aggregations/AggregationContainer.ts * add ext docs to table csv --------- (cherry picked from commit 23222d9) Co-authored-by: Laura Trotta <[email protected]> Co-authored-by: Quentin Pradet <[email protected]> * update ext doc table --------- Co-authored-by: Quentin Pradet <[email protected]>
1 parent 3057b74 commit 617466c

File tree

6 files changed

+116
-7
lines changed

6 files changed

+116
-7
lines changed

specification/_doc_ids/table.csv

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -649,6 +649,9 @@ search-aggregations-bucket-significantterms-aggregation,https://www.elastic.co/g
649649
search-aggregations-metrics-avg-aggregation,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/search-aggregations-metrics-avg-aggregation.html,,
650650
search-aggregations-metrics-boxplot-aggregation,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/search-aggregations-metrics-boxplot-aggregation.html,,
651651
search-aggregations-metrics-cardinality-aggregation,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/search-aggregations-metrics-cardinality-aggregation.html,,
652+
search-aggregations-metrics-cartesian-bounds-aggregation,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/search-aggregations-metrics-cartesian-bounds-aggregation.html,,
653+
search-aggregations-metrics-cartesian-centroid-aggregation,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/search-aggregations-metrics-cartesian-centroid-aggregation.html,,
654+
search-aggregations-change-point-aggregation,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/search-aggregations-change-point-aggregation.html,,
652655
search-aggregations-metrics-extendedstats-aggregation,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/search-aggregations-metrics-extendedstats-aggregation.html,,
653656
search-aggregations-pipeline-avg-bucket-aggregation,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/search-aggregations-pipeline-avg-bucket-aggregation.html,,
654657
search-aggregations-pipeline-bucket-path,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/search-aggregations-pipeline.html#buckets-path-syntax,,

specification/_types/Geo.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -95,12 +95,6 @@ export type GeoTile = string
9595

9696
/** A map hex cell (H3) reference */
9797
export type GeoHexCell = string
98-
99-
export class LatLon {
100-
lat: double
101-
lon: double
102-
}
103-
10498
/**
10599
* A latitude/longitude as a 2 dimensional point. It can be represented in various ways:
106100
* - as a `{lat, long}` object
@@ -128,6 +122,11 @@ export class LatLonGeoLocation {
128122
lon: double
129123
}
130124

125+
export class CartesianPoint {
126+
x: double
127+
y: double
128+
}
129+
131130
export class GeoHashLocation {
132131
geohash: GeoHash
133132
}

specification/_types/aggregations/Aggregate.ts

Lines changed: 79 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,14 @@
2020
import { CompositeAggregateKey } from '@_types/aggregations/bucket'
2121
import { AggregateName, Field, FieldValue, Metadata } from '@_types/common'
2222
import {
23+
CartesianPoint,
2324
GeoBounds,
2425
GeoHash,
2526
GeoHexCell,
2627
GeoLine,
2728
GeoLocation,
28-
GeoTile
29+
GeoTile,
30+
TopLeftBottomRightGeoBounds
2931
} from '@_types/Geo'
3032
import { double, integer, long } from '@_types/Numeric'
3133
import { DurationLarge, EpochTime, UnitMillis } from '@_types/Time'
@@ -59,11 +61,14 @@ export type Aggregate =
5961
| SimpleValueAggregate
6062
| DerivativeAggregate
6163
| BucketMetricValueAggregate
64+
| ChangePointAggregate
6265
// Multi value
6366
| StatsAggregate
6467
| StatsBucketAggregate
6568
| ExtendedStatsAggregate
6669
| ExtendedStatsBucketAggregate
70+
| CartesianBoundsAggregate
71+
| CartesianCentroidAggregate
6772
// Geo
6873
| GeoBoundsAggregate
6974
| GeoCentroidAggregate
@@ -322,6 +327,17 @@ export class ExtendedStatsAggregate extends StatsAggregate {
322327
/** @variant name=extended_stats_bucket */
323328
export class ExtendedStatsBucketAggregate extends ExtendedStatsAggregate {}
324329

330+
/** @variant name=cartesian_bounds */
331+
export class CartesianBoundsAggregate extends AggregateBase {
332+
bounds?: TopLeftBottomRightGeoBounds
333+
}
334+
335+
/** @variant name=cartesian_centroid */
336+
export class CartesianCentroidAggregate extends AggregateBase {
337+
count: long
338+
location?: CartesianPoint
339+
}
340+
325341
//----- Geo
326342

327343
/**
@@ -369,6 +385,68 @@ export class MultiBucketBase
369385
doc_count: long
370386
}
371387

388+
/** @variant name=change_point */
389+
export class ChangePointAggregate extends MultiBucketAggregateBase<ChangePointBucket> {
390+
type: ChangeType
391+
bucket?: ChangePointBucket
392+
}
393+
394+
export class ChangePointBucket extends MultiBucketBase {
395+
key: FieldValue
396+
}
397+
398+
/**
399+
* @variants typed_keys_quirk
400+
*/
401+
export type ChangeType =
402+
| Dip
403+
| DistributionChange
404+
| Indeterminable
405+
| NonStationary
406+
| Spike
407+
| Stationary
408+
| StepChange
409+
| TrendChange
410+
411+
export class AbstractChangePoint {
412+
p_value: double
413+
change_point: integer
414+
}
415+
416+
/** @variant name=dip */
417+
export class Dip extends AbstractChangePoint {}
418+
419+
/** @variant name=distribution_change */
420+
export class DistributionChange extends AbstractChangePoint {}
421+
422+
/** @variant name=spike */
423+
export class Spike extends AbstractChangePoint {}
424+
425+
/** @variant name=step_change */
426+
export class StepChange extends AbstractChangePoint {}
427+
428+
/** @variant name=indeterminable */
429+
export class Indeterminable {
430+
reason: string
431+
}
432+
433+
/** @variant name=non_stationary */
434+
export class NonStationary {
435+
p_value: double
436+
r_value: double
437+
trend: string
438+
}
439+
440+
/** @variant name=stationary */
441+
export class Stationary {}
442+
443+
/** @variant name=trend_change */
444+
export class TrendChange {
445+
p_value: double
446+
r_value: double
447+
change_point: integer
448+
}
449+
372450
/**
373451
* @variant name=histogram
374452
* @ext_doc_id search-aggregations-bucket-histogram-aggregation

specification/_types/aggregations/AggregationContainer.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ import {
6060
AverageAggregation,
6161
BoxplotAggregation,
6262
CardinalityAggregation,
63+
CartesianBoundsAggregation,
64+
CartesianCentroidAggregation,
6365
ExtendedStatsAggregation,
6466
GeoBoundsAggregation,
6567
GeoCentroidAggregation,
@@ -87,6 +89,7 @@ import {
8789
BucketScriptAggregation,
8890
BucketSelectorAggregation,
8991
BucketSortAggregation,
92+
ChangePointAggregation,
9093
CumulativeCardinalityAggregation,
9194
CumulativeSumAggregation,
9295
DerivativeAggregation,
@@ -183,13 +186,32 @@ export class AggregationContainer {
183186
* @ext_doc_id search-aggregations-metrics-cardinality-aggregation
184187
*/
185188
cardinality?: CardinalityAggregation
189+
/**
190+
* A metric aggregation that computes the spatial bounding box containing all values for a Point or Shape field.
191+
* @ext_doc_id search-aggregations-metrics-cartesian-bounds-aggregation
192+
*/
193+
cartesian_bounds?: CartesianBoundsAggregation
194+
/**
195+
* A metric aggregation that computes the weighted centroid from all coordinate values for point and shape fields.
196+
* @ext_doc_id search-aggregations-metrics-cartesian-centroid-aggregation
197+
*/
198+
cartesian_centroid?: CartesianCentroidAggregation
186199
/**
187200
* A multi-bucket aggregation that groups semi-structured text into buckets.
188201
* @ext_doc_id search-aggregations-bucket-categorize-text-aggregation
189202
* @availability stack stability=experimental
190203
* @availability serverless stability=experimental
191204
*/
192205
categorize_text?: CategorizeTextAggregation
206+
/**
207+
* A sibling pipeline that detects, spikes, dips, and change points in a metric.
208+
* Given a distribution of values provided by the sibling multi-bucket aggregation,
209+
* this aggregation indicates the bucket of any spike or dip and/or the bucket at which
210+
* the largest change in the distribution of values, if they are statistically significant.
211+
* There must be at least 22 bucketed values. Fewer than 1,000 is preferred.
212+
* @ext_doc_id search-aggregations-change-point-aggregation
213+
*/
214+
change_point?: ChangePointAggregation
193215
/**
194216
* A single bucket aggregation that selects child documents that have the specified type, as defined in a `join` field.
195217
* @ext_doc_id search-aggregations-bucket-children-aggregation
@@ -245,6 +267,7 @@ export class AggregationContainer {
245267
/**
246268
* A bucket aggregation which finds frequent item sets, a form of association rules mining that identifies items that often occur together.
247269
* @ext_doc_id search-aggregations-bucket-frequent-item-sets-aggregation
270+
* @aliases frequent_items
248271
*/
249272
frequent_item_sets?: FrequentItemSetsAggregation
250273
/**

specification/_types/aggregations/metric.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,10 @@ export class ExtendedStatsAggregation extends FormatMetricAggregationBase {
111111
sigma?: double
112112
}
113113

114+
export class CartesianBoundsAggregation extends MetricAggregationBase {}
115+
116+
export class CartesianCentroidAggregation extends MetricAggregationBase {}
117+
114118
/**
115119
* @ext_doc_id search-aggregations-metrics-geobounds-aggregation
116120
*/

specification/_types/aggregations/pipeline.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,8 @@ export class BucketSortAggregation extends Aggregation {
203203
sort?: Sort
204204
}
205205

206+
export class ChangePointAggregation extends PipelineAggregationBase {}
207+
206208
/**
207209
* @ext_doc_id search-aggregations-pipeline-cumulative-cardinality-aggregation
208210
*/

0 commit comments

Comments
 (0)