diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.aggconfig.toexpressionast.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.aggconfig.toexpressionast.md
index 99001e81fde49..0684b03e14032 100644
--- a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.aggconfig.toexpressionast.md
+++ b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.aggconfig.toexpressionast.md
@@ -7,11 +7,11 @@
Signature:
```typescript
-toExpressionAst(): ExpressionAstFunction | undefined;
+toExpressionAst(): ExpressionAstExpression | undefined;
```
Returns:
-`ExpressionAstFunction | undefined`
+`ExpressionAstExpression | undefined`
-Returns an ExpressionAst representing the function for this agg type.
+Returns an ExpressionAst representing the this agg type.
diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.aggfunctionsmapping.aggavg.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.aggfunctionsmapping.aggavg.md
new file mode 100644
index 0000000000000..c201cdb624583
--- /dev/null
+++ b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.aggfunctionsmapping.aggavg.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [AggFunctionsMapping](./kibana-plugin-plugins-data-public.aggfunctionsmapping.md) > [aggAvg](./kibana-plugin-plugins-data-public.aggfunctionsmapping.aggavg.md)
+
+## AggFunctionsMapping.aggAvg property
+
+Signature:
+
+```typescript
+aggAvg: ReturnType;
+```
diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.aggfunctionsmapping.aggbucketavg.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.aggfunctionsmapping.aggbucketavg.md
new file mode 100644
index 0000000000000..f3ae1f8c24e10
--- /dev/null
+++ b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.aggfunctionsmapping.aggbucketavg.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [AggFunctionsMapping](./kibana-plugin-plugins-data-public.aggfunctionsmapping.md) > [aggBucketAvg](./kibana-plugin-plugins-data-public.aggfunctionsmapping.aggbucketavg.md)
+
+## AggFunctionsMapping.aggBucketAvg property
+
+Signature:
+
+```typescript
+aggBucketAvg: ReturnType;
+```
diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.aggfunctionsmapping.aggbucketmax.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.aggfunctionsmapping.aggbucketmax.md
new file mode 100644
index 0000000000000..9623e94f0523f
--- /dev/null
+++ b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.aggfunctionsmapping.aggbucketmax.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [AggFunctionsMapping](./kibana-plugin-plugins-data-public.aggfunctionsmapping.md) > [aggBucketMax](./kibana-plugin-plugins-data-public.aggfunctionsmapping.aggbucketmax.md)
+
+## AggFunctionsMapping.aggBucketMax property
+
+Signature:
+
+```typescript
+aggBucketMax: ReturnType;
+```
diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.aggfunctionsmapping.aggbucketmin.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.aggfunctionsmapping.aggbucketmin.md
new file mode 100644
index 0000000000000..071c4fb0de82c
--- /dev/null
+++ b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.aggfunctionsmapping.aggbucketmin.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [AggFunctionsMapping](./kibana-plugin-plugins-data-public.aggfunctionsmapping.md) > [aggBucketMin](./kibana-plugin-plugins-data-public.aggfunctionsmapping.aggbucketmin.md)
+
+## AggFunctionsMapping.aggBucketMin property
+
+Signature:
+
+```typescript
+aggBucketMin: ReturnType;
+```
diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.aggfunctionsmapping.aggbucketsum.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.aggfunctionsmapping.aggbucketsum.md
new file mode 100644
index 0000000000000..51770e0d5ef5b
--- /dev/null
+++ b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.aggfunctionsmapping.aggbucketsum.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [AggFunctionsMapping](./kibana-plugin-plugins-data-public.aggfunctionsmapping.md) > [aggBucketSum](./kibana-plugin-plugins-data-public.aggfunctionsmapping.aggbucketsum.md)
+
+## AggFunctionsMapping.aggBucketSum property
+
+Signature:
+
+```typescript
+aggBucketSum: ReturnType;
+```
diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.aggfunctionsmapping.aggcardinality.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.aggfunctionsmapping.aggcardinality.md
new file mode 100644
index 0000000000000..eaa0604571399
--- /dev/null
+++ b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.aggfunctionsmapping.aggcardinality.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [AggFunctionsMapping](./kibana-plugin-plugins-data-public.aggfunctionsmapping.md) > [aggCardinality](./kibana-plugin-plugins-data-public.aggfunctionsmapping.aggcardinality.md)
+
+## AggFunctionsMapping.aggCardinality property
+
+Signature:
+
+```typescript
+aggCardinality: ReturnType;
+```
diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.aggfunctionsmapping.aggcount.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.aggfunctionsmapping.aggcount.md
new file mode 100644
index 0000000000000..e0ab80bcd5dd0
--- /dev/null
+++ b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.aggfunctionsmapping.aggcount.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [AggFunctionsMapping](./kibana-plugin-plugins-data-public.aggfunctionsmapping.md) > [aggCount](./kibana-plugin-plugins-data-public.aggfunctionsmapping.aggcount.md)
+
+## AggFunctionsMapping.aggCount property
+
+Signature:
+
+```typescript
+aggCount: ReturnType;
+```
diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.aggfunctionsmapping.aggcumulativesum.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.aggfunctionsmapping.aggcumulativesum.md
new file mode 100644
index 0000000000000..d1befc3fa4ad6
--- /dev/null
+++ b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.aggfunctionsmapping.aggcumulativesum.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [AggFunctionsMapping](./kibana-plugin-plugins-data-public.aggfunctionsmapping.md) > [aggCumulativeSum](./kibana-plugin-plugins-data-public.aggfunctionsmapping.aggcumulativesum.md)
+
+## AggFunctionsMapping.aggCumulativeSum property
+
+Signature:
+
+```typescript
+aggCumulativeSum: ReturnType;
+```
diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.aggfunctionsmapping.aggdatehistogram.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.aggfunctionsmapping.aggdatehistogram.md
new file mode 100644
index 0000000000000..edf96654c63f0
--- /dev/null
+++ b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.aggfunctionsmapping.aggdatehistogram.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [AggFunctionsMapping](./kibana-plugin-plugins-data-public.aggfunctionsmapping.md) > [aggDateHistogram](./kibana-plugin-plugins-data-public.aggfunctionsmapping.aggdatehistogram.md)
+
+## AggFunctionsMapping.aggDateHistogram property
+
+Signature:
+
+```typescript
+aggDateHistogram: ReturnType;
+```
diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.aggfunctionsmapping.aggdaterange.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.aggfunctionsmapping.aggdaterange.md
new file mode 100644
index 0000000000000..770a3fe049d44
--- /dev/null
+++ b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.aggfunctionsmapping.aggdaterange.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [AggFunctionsMapping](./kibana-plugin-plugins-data-public.aggfunctionsmapping.md) > [aggDateRange](./kibana-plugin-plugins-data-public.aggfunctionsmapping.aggdaterange.md)
+
+## AggFunctionsMapping.aggDateRange property
+
+Signature:
+
+```typescript
+aggDateRange: ReturnType;
+```
diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.aggfunctionsmapping.aggderivative.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.aggfunctionsmapping.aggderivative.md
new file mode 100644
index 0000000000000..db97b3224914c
--- /dev/null
+++ b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.aggfunctionsmapping.aggderivative.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [AggFunctionsMapping](./kibana-plugin-plugins-data-public.aggfunctionsmapping.md) > [aggDerivative](./kibana-plugin-plugins-data-public.aggfunctionsmapping.aggderivative.md)
+
+## AggFunctionsMapping.aggDerivative property
+
+Signature:
+
+```typescript
+aggDerivative: ReturnType;
+```
diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.aggfunctionsmapping.aggfilter.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.aggfunctionsmapping.aggfilter.md
new file mode 100644
index 0000000000000..a862d0b8edc47
--- /dev/null
+++ b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.aggfunctionsmapping.aggfilter.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [AggFunctionsMapping](./kibana-plugin-plugins-data-public.aggfunctionsmapping.md) > [aggFilter](./kibana-plugin-plugins-data-public.aggfunctionsmapping.aggfilter.md)
+
+## AggFunctionsMapping.aggFilter property
+
+Signature:
+
+```typescript
+aggFilter: ReturnType;
+```
diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.aggfunctionsmapping.aggfilters.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.aggfunctionsmapping.aggfilters.md
new file mode 100644
index 0000000000000..1e3b4a2945a41
--- /dev/null
+++ b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.aggfunctionsmapping.aggfilters.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [AggFunctionsMapping](./kibana-plugin-plugins-data-public.aggfunctionsmapping.md) > [aggFilters](./kibana-plugin-plugins-data-public.aggfunctionsmapping.aggfilters.md)
+
+## AggFunctionsMapping.aggFilters property
+
+Signature:
+
+```typescript
+aggFilters: ReturnType;
+```
diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.aggfunctionsmapping.agggeobounds.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.aggfunctionsmapping.agggeobounds.md
new file mode 100644
index 0000000000000..48191ee288470
--- /dev/null
+++ b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.aggfunctionsmapping.agggeobounds.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [AggFunctionsMapping](./kibana-plugin-plugins-data-public.aggfunctionsmapping.md) > [aggGeoBounds](./kibana-plugin-plugins-data-public.aggfunctionsmapping.agggeobounds.md)
+
+## AggFunctionsMapping.aggGeoBounds property
+
+Signature:
+
+```typescript
+aggGeoBounds: ReturnType;
+```
diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.aggfunctionsmapping.agggeocentroid.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.aggfunctionsmapping.agggeocentroid.md
new file mode 100644
index 0000000000000..bde4347681545
--- /dev/null
+++ b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.aggfunctionsmapping.agggeocentroid.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [AggFunctionsMapping](./kibana-plugin-plugins-data-public.aggfunctionsmapping.md) > [aggGeoCentroid](./kibana-plugin-plugins-data-public.aggfunctionsmapping.agggeocentroid.md)
+
+## AggFunctionsMapping.aggGeoCentroid property
+
+Signature:
+
+```typescript
+aggGeoCentroid: ReturnType;
+```
diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.aggfunctionsmapping.agggeohash.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.aggfunctionsmapping.agggeohash.md
new file mode 100644
index 0000000000000..2636d64609c07
--- /dev/null
+++ b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.aggfunctionsmapping.agggeohash.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [AggFunctionsMapping](./kibana-plugin-plugins-data-public.aggfunctionsmapping.md) > [aggGeoHash](./kibana-plugin-plugins-data-public.aggfunctionsmapping.agggeohash.md)
+
+## AggFunctionsMapping.aggGeoHash property
+
+Signature:
+
+```typescript
+aggGeoHash: ReturnType;
+```
diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.aggfunctionsmapping.agggeotile.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.aggfunctionsmapping.agggeotile.md
new file mode 100644
index 0000000000000..4a3e50acb836b
--- /dev/null
+++ b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.aggfunctionsmapping.agggeotile.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [AggFunctionsMapping](./kibana-plugin-plugins-data-public.aggfunctionsmapping.md) > [aggGeoTile](./kibana-plugin-plugins-data-public.aggfunctionsmapping.agggeotile.md)
+
+## AggFunctionsMapping.aggGeoTile property
+
+Signature:
+
+```typescript
+aggGeoTile: ReturnType;
+```
diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.aggfunctionsmapping.agghistogram.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.aggfunctionsmapping.agghistogram.md
new file mode 100644
index 0000000000000..9b89c6f4b44f8
--- /dev/null
+++ b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.aggfunctionsmapping.agghistogram.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [AggFunctionsMapping](./kibana-plugin-plugins-data-public.aggfunctionsmapping.md) > [aggHistogram](./kibana-plugin-plugins-data-public.aggfunctionsmapping.agghistogram.md)
+
+## AggFunctionsMapping.aggHistogram property
+
+Signature:
+
+```typescript
+aggHistogram: ReturnType;
+```
diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.aggfunctionsmapping.aggiprange.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.aggfunctionsmapping.aggiprange.md
new file mode 100644
index 0000000000000..24085d0f185d3
--- /dev/null
+++ b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.aggfunctionsmapping.aggiprange.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [AggFunctionsMapping](./kibana-plugin-plugins-data-public.aggfunctionsmapping.md) > [aggIpRange](./kibana-plugin-plugins-data-public.aggfunctionsmapping.aggiprange.md)
+
+## AggFunctionsMapping.aggIpRange property
+
+Signature:
+
+```typescript
+aggIpRange: ReturnType;
+```
diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.aggfunctionsmapping.aggmax.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.aggfunctionsmapping.aggmax.md
new file mode 100644
index 0000000000000..a9fc4eb8c1b62
--- /dev/null
+++ b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.aggfunctionsmapping.aggmax.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [AggFunctionsMapping](./kibana-plugin-plugins-data-public.aggfunctionsmapping.md) > [aggMax](./kibana-plugin-plugins-data-public.aggfunctionsmapping.aggmax.md)
+
+## AggFunctionsMapping.aggMax property
+
+Signature:
+
+```typescript
+aggMax: ReturnType;
+```
diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.aggfunctionsmapping.aggmedian.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.aggfunctionsmapping.aggmedian.md
new file mode 100644
index 0000000000000..ee266c05cce53
--- /dev/null
+++ b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.aggfunctionsmapping.aggmedian.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [AggFunctionsMapping](./kibana-plugin-plugins-data-public.aggfunctionsmapping.md) > [aggMedian](./kibana-plugin-plugins-data-public.aggfunctionsmapping.aggmedian.md)
+
+## AggFunctionsMapping.aggMedian property
+
+Signature:
+
+```typescript
+aggMedian: ReturnType;
+```
diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.aggfunctionsmapping.aggmin.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.aggfunctionsmapping.aggmin.md
new file mode 100644
index 0000000000000..d1af0e02d961b
--- /dev/null
+++ b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.aggfunctionsmapping.aggmin.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [AggFunctionsMapping](./kibana-plugin-plugins-data-public.aggfunctionsmapping.md) > [aggMin](./kibana-plugin-plugins-data-public.aggfunctionsmapping.aggmin.md)
+
+## AggFunctionsMapping.aggMin property
+
+Signature:
+
+```typescript
+aggMin: ReturnType;
+```
diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.aggfunctionsmapping.aggmovingavg.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.aggfunctionsmapping.aggmovingavg.md
new file mode 100644
index 0000000000000..954bb4c427c50
--- /dev/null
+++ b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.aggfunctionsmapping.aggmovingavg.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [AggFunctionsMapping](./kibana-plugin-plugins-data-public.aggfunctionsmapping.md) > [aggMovingAvg](./kibana-plugin-plugins-data-public.aggfunctionsmapping.aggmovingavg.md)
+
+## AggFunctionsMapping.aggMovingAvg property
+
+Signature:
+
+```typescript
+aggMovingAvg: ReturnType;
+```
diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.aggfunctionsmapping.aggpercentileranks.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.aggfunctionsmapping.aggpercentileranks.md
new file mode 100644
index 0000000000000..a332b986ea70b
--- /dev/null
+++ b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.aggfunctionsmapping.aggpercentileranks.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [AggFunctionsMapping](./kibana-plugin-plugins-data-public.aggfunctionsmapping.md) > [aggPercentileRanks](./kibana-plugin-plugins-data-public.aggfunctionsmapping.aggpercentileranks.md)
+
+## AggFunctionsMapping.aggPercentileRanks property
+
+Signature:
+
+```typescript
+aggPercentileRanks: ReturnType;
+```
diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.aggfunctionsmapping.aggpercentiles.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.aggfunctionsmapping.aggpercentiles.md
new file mode 100644
index 0000000000000..14f279ea8d7c4
--- /dev/null
+++ b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.aggfunctionsmapping.aggpercentiles.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [AggFunctionsMapping](./kibana-plugin-plugins-data-public.aggfunctionsmapping.md) > [aggPercentiles](./kibana-plugin-plugins-data-public.aggfunctionsmapping.aggpercentiles.md)
+
+## AggFunctionsMapping.aggPercentiles property
+
+Signature:
+
+```typescript
+aggPercentiles: ReturnType;
+```
diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.aggfunctionsmapping.aggrange.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.aggfunctionsmapping.aggrange.md
new file mode 100644
index 0000000000000..8dab1873fc637
--- /dev/null
+++ b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.aggfunctionsmapping.aggrange.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [AggFunctionsMapping](./kibana-plugin-plugins-data-public.aggfunctionsmapping.md) > [aggRange](./kibana-plugin-plugins-data-public.aggfunctionsmapping.aggrange.md)
+
+## AggFunctionsMapping.aggRange property
+
+Signature:
+
+```typescript
+aggRange: ReturnType;
+```
diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.aggfunctionsmapping.aggserialdiff.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.aggfunctionsmapping.aggserialdiff.md
new file mode 100644
index 0000000000000..ed0eaa8226117
--- /dev/null
+++ b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.aggfunctionsmapping.aggserialdiff.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [AggFunctionsMapping](./kibana-plugin-plugins-data-public.aggfunctionsmapping.md) > [aggSerialDiff](./kibana-plugin-plugins-data-public.aggfunctionsmapping.aggserialdiff.md)
+
+## AggFunctionsMapping.aggSerialDiff property
+
+Signature:
+
+```typescript
+aggSerialDiff: ReturnType;
+```
diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.aggfunctionsmapping.aggsignificantterms.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.aggfunctionsmapping.aggsignificantterms.md
new file mode 100644
index 0000000000000..22c5ffd6f30b5
--- /dev/null
+++ b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.aggfunctionsmapping.aggsignificantterms.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [AggFunctionsMapping](./kibana-plugin-plugins-data-public.aggfunctionsmapping.md) > [aggSignificantTerms](./kibana-plugin-plugins-data-public.aggfunctionsmapping.aggsignificantterms.md)
+
+## AggFunctionsMapping.aggSignificantTerms property
+
+Signature:
+
+```typescript
+aggSignificantTerms: ReturnType;
+```
diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.aggfunctionsmapping.aggstddeviation.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.aggfunctionsmapping.aggstddeviation.md
new file mode 100644
index 0000000000000..f5c349f5586b4
--- /dev/null
+++ b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.aggfunctionsmapping.aggstddeviation.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [AggFunctionsMapping](./kibana-plugin-plugins-data-public.aggfunctionsmapping.md) > [aggStdDeviation](./kibana-plugin-plugins-data-public.aggfunctionsmapping.aggstddeviation.md)
+
+## AggFunctionsMapping.aggStdDeviation property
+
+Signature:
+
+```typescript
+aggStdDeviation: ReturnType;
+```
diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.aggfunctionsmapping.aggsum.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.aggfunctionsmapping.aggsum.md
new file mode 100644
index 0000000000000..977f7ebf33a53
--- /dev/null
+++ b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.aggfunctionsmapping.aggsum.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [AggFunctionsMapping](./kibana-plugin-plugins-data-public.aggfunctionsmapping.md) > [aggSum](./kibana-plugin-plugins-data-public.aggfunctionsmapping.aggsum.md)
+
+## AggFunctionsMapping.aggSum property
+
+Signature:
+
+```typescript
+aggSum: ReturnType;
+```
diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.aggfunctionsmapping.aggterms.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.aggfunctionsmapping.aggterms.md
new file mode 100644
index 0000000000000..b42e643859e73
--- /dev/null
+++ b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.aggfunctionsmapping.aggterms.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [AggFunctionsMapping](./kibana-plugin-plugins-data-public.aggfunctionsmapping.md) > [aggTerms](./kibana-plugin-plugins-data-public.aggfunctionsmapping.aggterms.md)
+
+## AggFunctionsMapping.aggTerms property
+
+Signature:
+
+```typescript
+aggTerms: ReturnType;
+```
diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.aggfunctionsmapping.aggtophit.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.aggfunctionsmapping.aggtophit.md
new file mode 100644
index 0000000000000..681d6a0b95489
--- /dev/null
+++ b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.aggfunctionsmapping.aggtophit.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [AggFunctionsMapping](./kibana-plugin-plugins-data-public.aggfunctionsmapping.md) > [aggTopHit](./kibana-plugin-plugins-data-public.aggfunctionsmapping.aggtophit.md)
+
+## AggFunctionsMapping.aggTopHit property
+
+Signature:
+
+```typescript
+aggTopHit: ReturnType;
+```
diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.aggfunctionsmapping.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.aggfunctionsmapping.md
new file mode 100644
index 0000000000000..b175b8d473d34
--- /dev/null
+++ b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.aggfunctionsmapping.md
@@ -0,0 +1,51 @@
+
+
+[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [AggFunctionsMapping](./kibana-plugin-plugins-data-public.aggfunctionsmapping.md)
+
+## AggFunctionsMapping interface
+
+A global list of the expression function definitions for each agg type function.
+
+Signature:
+
+```typescript
+export interface AggFunctionsMapping
+```
+
+## Properties
+
+| Property | Type | Description |
+| --- | --- | --- |
+| [aggAvg](./kibana-plugin-plugins-data-public.aggfunctionsmapping.aggavg.md) | ReturnType<typeof aggAvg>
| |
+| [aggBucketAvg](./kibana-plugin-plugins-data-public.aggfunctionsmapping.aggbucketavg.md) | ReturnType<typeof aggBucketAvg>
| |
+| [aggBucketMax](./kibana-plugin-plugins-data-public.aggfunctionsmapping.aggbucketmax.md) | ReturnType<typeof aggBucketMax>
| |
+| [aggBucketMin](./kibana-plugin-plugins-data-public.aggfunctionsmapping.aggbucketmin.md) | ReturnType<typeof aggBucketMin>
| |
+| [aggBucketSum](./kibana-plugin-plugins-data-public.aggfunctionsmapping.aggbucketsum.md) | ReturnType<typeof aggBucketSum>
| |
+| [aggCardinality](./kibana-plugin-plugins-data-public.aggfunctionsmapping.aggcardinality.md) | ReturnType<typeof aggCardinality>
| |
+| [aggCount](./kibana-plugin-plugins-data-public.aggfunctionsmapping.aggcount.md) | ReturnType<typeof aggCount>
| |
+| [aggCumulativeSum](./kibana-plugin-plugins-data-public.aggfunctionsmapping.aggcumulativesum.md) | ReturnType<typeof aggCumulativeSum>
| |
+| [aggDateHistogram](./kibana-plugin-plugins-data-public.aggfunctionsmapping.aggdatehistogram.md) | ReturnType<typeof aggDateHistogram>
| |
+| [aggDateRange](./kibana-plugin-plugins-data-public.aggfunctionsmapping.aggdaterange.md) | ReturnType<typeof aggDateRange>
| |
+| [aggDerivative](./kibana-plugin-plugins-data-public.aggfunctionsmapping.aggderivative.md) | ReturnType<typeof aggDerivative>
| |
+| [aggFilter](./kibana-plugin-plugins-data-public.aggfunctionsmapping.aggfilter.md) | ReturnType<typeof aggFilter>
| |
+| [aggFilters](./kibana-plugin-plugins-data-public.aggfunctionsmapping.aggfilters.md) | ReturnType<typeof aggFilters>
| |
+| [aggGeoBounds](./kibana-plugin-plugins-data-public.aggfunctionsmapping.agggeobounds.md) | ReturnType<typeof aggGeoBounds>
| |
+| [aggGeoCentroid](./kibana-plugin-plugins-data-public.aggfunctionsmapping.agggeocentroid.md) | ReturnType<typeof aggGeoCentroid>
| |
+| [aggGeoHash](./kibana-plugin-plugins-data-public.aggfunctionsmapping.agggeohash.md) | ReturnType<typeof aggGeoHash>
| |
+| [aggGeoTile](./kibana-plugin-plugins-data-public.aggfunctionsmapping.agggeotile.md) | ReturnType<typeof aggGeoTile>
| |
+| [aggHistogram](./kibana-plugin-plugins-data-public.aggfunctionsmapping.agghistogram.md) | ReturnType<typeof aggHistogram>
| |
+| [aggIpRange](./kibana-plugin-plugins-data-public.aggfunctionsmapping.aggiprange.md) | ReturnType<typeof aggIpRange>
| |
+| [aggMax](./kibana-plugin-plugins-data-public.aggfunctionsmapping.aggmax.md) | ReturnType<typeof aggMax>
| |
+| [aggMedian](./kibana-plugin-plugins-data-public.aggfunctionsmapping.aggmedian.md) | ReturnType<typeof aggMedian>
| |
+| [aggMin](./kibana-plugin-plugins-data-public.aggfunctionsmapping.aggmin.md) | ReturnType<typeof aggMin>
| |
+| [aggMovingAvg](./kibana-plugin-plugins-data-public.aggfunctionsmapping.aggmovingavg.md) | ReturnType<typeof aggMovingAvg>
| |
+| [aggPercentileRanks](./kibana-plugin-plugins-data-public.aggfunctionsmapping.aggpercentileranks.md) | ReturnType<typeof aggPercentileRanks>
| |
+| [aggPercentiles](./kibana-plugin-plugins-data-public.aggfunctionsmapping.aggpercentiles.md) | ReturnType<typeof aggPercentiles>
| |
+| [aggRange](./kibana-plugin-plugins-data-public.aggfunctionsmapping.aggrange.md) | ReturnType<typeof aggRange>
| |
+| [aggSerialDiff](./kibana-plugin-plugins-data-public.aggfunctionsmapping.aggserialdiff.md) | ReturnType<typeof aggSerialDiff>
| |
+| [aggSignificantTerms](./kibana-plugin-plugins-data-public.aggfunctionsmapping.aggsignificantterms.md) | ReturnType<typeof aggSignificantTerms>
| |
+| [aggStdDeviation](./kibana-plugin-plugins-data-public.aggfunctionsmapping.aggstddeviation.md) | ReturnType<typeof aggStdDeviation>
| |
+| [aggSum](./kibana-plugin-plugins-data-public.aggfunctionsmapping.aggsum.md) | ReturnType<typeof aggSum>
| |
+| [aggTerms](./kibana-plugin-plugins-data-public.aggfunctionsmapping.aggterms.md) | ReturnType<typeof aggTerms>
| |
+| [aggTopHit](./kibana-plugin-plugins-data-public.aggfunctionsmapping.aggtophit.md) | ReturnType<typeof aggTopHit>
| |
+
diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpatternloadexpressionfunctiondefinition.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpatternloadexpressionfunctiondefinition.md
new file mode 100644
index 0000000000000..ec18a4da2eef7
--- /dev/null
+++ b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpatternloadexpressionfunctiondefinition.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [IndexPatternLoadExpressionFunctionDefinition](./kibana-plugin-plugins-data-public.indexpatternloadexpressionfunctiondefinition.md)
+
+## IndexPatternLoadExpressionFunctionDefinition type
+
+Signature:
+
+```typescript
+export declare type IndexPatternLoadExpressionFunctionDefinition = ExpressionFunctionDefinition;
+```
diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.md
index 08ed14b92d24c..8de3821161ab4 100644
--- a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.md
+++ b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.md
@@ -52,6 +52,7 @@
| Interface | Description |
| --- | --- |
+| [AggFunctionsMapping](./kibana-plugin-plugins-data-public.aggfunctionsmapping.md) | A global list of the expression function definitions for each agg type function. |
| [AggParamOption](./kibana-plugin-plugins-data-public.aggparamoption.md) | |
| [ApplyGlobalFilterActionContext](./kibana-plugin-plugins-data-public.applyglobalfilteractioncontext.md) | |
| [DataPublicPluginSetup](./kibana-plugin-plugins-data-public.datapublicpluginsetup.md) | Data plugin public Setup contract |
@@ -162,6 +163,7 @@
| [IFieldParamType](./kibana-plugin-plugins-data-public.ifieldparamtype.md) | |
| [IMetricAggType](./kibana-plugin-plugins-data-public.imetricaggtype.md) | |
| [IndexPatternAggRestrictions](./kibana-plugin-plugins-data-public.indexpatternaggrestrictions.md) | |
+| [IndexPatternLoadExpressionFunctionDefinition](./kibana-plugin-plugins-data-public.indexpatternloadexpressionfunctiondefinition.md) | |
| [IndexPatternsContract](./kibana-plugin-plugins-data-public.indexpatternscontract.md) | |
| [IndexPatternSelectProps](./kibana-plugin-plugins-data-public.indexpatternselectprops.md) | |
| [InputTimeRange](./kibana-plugin-plugins-data-public.inputtimerange.md) | |
diff --git a/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.aggfunctionsmapping.aggavg.md b/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.aggfunctionsmapping.aggavg.md
new file mode 100644
index 0000000000000..dd5884c0a7c47
--- /dev/null
+++ b/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.aggfunctionsmapping.aggavg.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [kibana-plugin-plugins-data-server](./kibana-plugin-plugins-data-server.md) > [AggFunctionsMapping](./kibana-plugin-plugins-data-server.aggfunctionsmapping.md) > [aggAvg](./kibana-plugin-plugins-data-server.aggfunctionsmapping.aggavg.md)
+
+## AggFunctionsMapping.aggAvg property
+
+Signature:
+
+```typescript
+aggAvg: ReturnType;
+```
diff --git a/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.aggfunctionsmapping.aggbucketavg.md b/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.aggfunctionsmapping.aggbucketavg.md
new file mode 100644
index 0000000000000..9a36328eade20
--- /dev/null
+++ b/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.aggfunctionsmapping.aggbucketavg.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [kibana-plugin-plugins-data-server](./kibana-plugin-plugins-data-server.md) > [AggFunctionsMapping](./kibana-plugin-plugins-data-server.aggfunctionsmapping.md) > [aggBucketAvg](./kibana-plugin-plugins-data-server.aggfunctionsmapping.aggbucketavg.md)
+
+## AggFunctionsMapping.aggBucketAvg property
+
+Signature:
+
+```typescript
+aggBucketAvg: ReturnType;
+```
diff --git a/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.aggfunctionsmapping.aggbucketmax.md b/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.aggfunctionsmapping.aggbucketmax.md
new file mode 100644
index 0000000000000..7880300497a8c
--- /dev/null
+++ b/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.aggfunctionsmapping.aggbucketmax.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [kibana-plugin-plugins-data-server](./kibana-plugin-plugins-data-server.md) > [AggFunctionsMapping](./kibana-plugin-plugins-data-server.aggfunctionsmapping.md) > [aggBucketMax](./kibana-plugin-plugins-data-server.aggfunctionsmapping.aggbucketmax.md)
+
+## AggFunctionsMapping.aggBucketMax property
+
+Signature:
+
+```typescript
+aggBucketMax: ReturnType;
+```
diff --git a/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.aggfunctionsmapping.aggbucketmin.md b/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.aggfunctionsmapping.aggbucketmin.md
new file mode 100644
index 0000000000000..d806b610e4ad2
--- /dev/null
+++ b/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.aggfunctionsmapping.aggbucketmin.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [kibana-plugin-plugins-data-server](./kibana-plugin-plugins-data-server.md) > [AggFunctionsMapping](./kibana-plugin-plugins-data-server.aggfunctionsmapping.md) > [aggBucketMin](./kibana-plugin-plugins-data-server.aggfunctionsmapping.aggbucketmin.md)
+
+## AggFunctionsMapping.aggBucketMin property
+
+Signature:
+
+```typescript
+aggBucketMin: ReturnType;
+```
diff --git a/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.aggfunctionsmapping.aggbucketsum.md b/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.aggfunctionsmapping.aggbucketsum.md
new file mode 100644
index 0000000000000..17f1d24f2736f
--- /dev/null
+++ b/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.aggfunctionsmapping.aggbucketsum.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [kibana-plugin-plugins-data-server](./kibana-plugin-plugins-data-server.md) > [AggFunctionsMapping](./kibana-plugin-plugins-data-server.aggfunctionsmapping.md) > [aggBucketSum](./kibana-plugin-plugins-data-server.aggfunctionsmapping.aggbucketsum.md)
+
+## AggFunctionsMapping.aggBucketSum property
+
+Signature:
+
+```typescript
+aggBucketSum: ReturnType;
+```
diff --git a/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.aggfunctionsmapping.aggcardinality.md b/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.aggfunctionsmapping.aggcardinality.md
new file mode 100644
index 0000000000000..fd31251fd6b22
--- /dev/null
+++ b/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.aggfunctionsmapping.aggcardinality.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [kibana-plugin-plugins-data-server](./kibana-plugin-plugins-data-server.md) > [AggFunctionsMapping](./kibana-plugin-plugins-data-server.aggfunctionsmapping.md) > [aggCardinality](./kibana-plugin-plugins-data-server.aggfunctionsmapping.aggcardinality.md)
+
+## AggFunctionsMapping.aggCardinality property
+
+Signature:
+
+```typescript
+aggCardinality: ReturnType;
+```
diff --git a/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.aggfunctionsmapping.aggcount.md b/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.aggfunctionsmapping.aggcount.md
new file mode 100644
index 0000000000000..65aae8bc15dfe
--- /dev/null
+++ b/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.aggfunctionsmapping.aggcount.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [kibana-plugin-plugins-data-server](./kibana-plugin-plugins-data-server.md) > [AggFunctionsMapping](./kibana-plugin-plugins-data-server.aggfunctionsmapping.md) > [aggCount](./kibana-plugin-plugins-data-server.aggfunctionsmapping.aggcount.md)
+
+## AggFunctionsMapping.aggCount property
+
+Signature:
+
+```typescript
+aggCount: ReturnType;
+```
diff --git a/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.aggfunctionsmapping.aggcumulativesum.md b/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.aggfunctionsmapping.aggcumulativesum.md
new file mode 100644
index 0000000000000..7c5d29391594a
--- /dev/null
+++ b/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.aggfunctionsmapping.aggcumulativesum.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [kibana-plugin-plugins-data-server](./kibana-plugin-plugins-data-server.md) > [AggFunctionsMapping](./kibana-plugin-plugins-data-server.aggfunctionsmapping.md) > [aggCumulativeSum](./kibana-plugin-plugins-data-server.aggfunctionsmapping.aggcumulativesum.md)
+
+## AggFunctionsMapping.aggCumulativeSum property
+
+Signature:
+
+```typescript
+aggCumulativeSum: ReturnType;
+```
diff --git a/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.aggfunctionsmapping.aggdatehistogram.md b/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.aggfunctionsmapping.aggdatehistogram.md
new file mode 100644
index 0000000000000..ca018cc6881e2
--- /dev/null
+++ b/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.aggfunctionsmapping.aggdatehistogram.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [kibana-plugin-plugins-data-server](./kibana-plugin-plugins-data-server.md) > [AggFunctionsMapping](./kibana-plugin-plugins-data-server.aggfunctionsmapping.md) > [aggDateHistogram](./kibana-plugin-plugins-data-server.aggfunctionsmapping.aggdatehistogram.md)
+
+## AggFunctionsMapping.aggDateHistogram property
+
+Signature:
+
+```typescript
+aggDateHistogram: ReturnType;
+```
diff --git a/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.aggfunctionsmapping.aggdaterange.md b/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.aggfunctionsmapping.aggdaterange.md
new file mode 100644
index 0000000000000..dc2019e761e49
--- /dev/null
+++ b/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.aggfunctionsmapping.aggdaterange.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [kibana-plugin-plugins-data-server](./kibana-plugin-plugins-data-server.md) > [AggFunctionsMapping](./kibana-plugin-plugins-data-server.aggfunctionsmapping.md) > [aggDateRange](./kibana-plugin-plugins-data-server.aggfunctionsmapping.aggdaterange.md)
+
+## AggFunctionsMapping.aggDateRange property
+
+Signature:
+
+```typescript
+aggDateRange: ReturnType;
+```
diff --git a/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.aggfunctionsmapping.aggderivative.md b/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.aggfunctionsmapping.aggderivative.md
new file mode 100644
index 0000000000000..c77054ca0a39b
--- /dev/null
+++ b/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.aggfunctionsmapping.aggderivative.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [kibana-plugin-plugins-data-server](./kibana-plugin-plugins-data-server.md) > [AggFunctionsMapping](./kibana-plugin-plugins-data-server.aggfunctionsmapping.md) > [aggDerivative](./kibana-plugin-plugins-data-server.aggfunctionsmapping.aggderivative.md)
+
+## AggFunctionsMapping.aggDerivative property
+
+Signature:
+
+```typescript
+aggDerivative: ReturnType;
+```
diff --git a/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.aggfunctionsmapping.aggfilter.md b/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.aggfunctionsmapping.aggfilter.md
new file mode 100644
index 0000000000000..6f77cd69ca1a6
--- /dev/null
+++ b/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.aggfunctionsmapping.aggfilter.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [kibana-plugin-plugins-data-server](./kibana-plugin-plugins-data-server.md) > [AggFunctionsMapping](./kibana-plugin-plugins-data-server.aggfunctionsmapping.md) > [aggFilter](./kibana-plugin-plugins-data-server.aggfunctionsmapping.aggfilter.md)
+
+## AggFunctionsMapping.aggFilter property
+
+Signature:
+
+```typescript
+aggFilter: ReturnType;
+```
diff --git a/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.aggfunctionsmapping.aggfilters.md b/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.aggfunctionsmapping.aggfilters.md
new file mode 100644
index 0000000000000..59cc96785ddb0
--- /dev/null
+++ b/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.aggfunctionsmapping.aggfilters.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [kibana-plugin-plugins-data-server](./kibana-plugin-plugins-data-server.md) > [AggFunctionsMapping](./kibana-plugin-plugins-data-server.aggfunctionsmapping.md) > [aggFilters](./kibana-plugin-plugins-data-server.aggfunctionsmapping.aggfilters.md)
+
+## AggFunctionsMapping.aggFilters property
+
+Signature:
+
+```typescript
+aggFilters: ReturnType;
+```
diff --git a/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.aggfunctionsmapping.agggeobounds.md b/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.aggfunctionsmapping.agggeobounds.md
new file mode 100644
index 0000000000000..e43df684f792b
--- /dev/null
+++ b/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.aggfunctionsmapping.agggeobounds.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [kibana-plugin-plugins-data-server](./kibana-plugin-plugins-data-server.md) > [AggFunctionsMapping](./kibana-plugin-plugins-data-server.aggfunctionsmapping.md) > [aggGeoBounds](./kibana-plugin-plugins-data-server.aggfunctionsmapping.agggeobounds.md)
+
+## AggFunctionsMapping.aggGeoBounds property
+
+Signature:
+
+```typescript
+aggGeoBounds: ReturnType;
+```
diff --git a/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.aggfunctionsmapping.agggeocentroid.md b/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.aggfunctionsmapping.agggeocentroid.md
new file mode 100644
index 0000000000000..bad7afcdd0179
--- /dev/null
+++ b/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.aggfunctionsmapping.agggeocentroid.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [kibana-plugin-plugins-data-server](./kibana-plugin-plugins-data-server.md) > [AggFunctionsMapping](./kibana-plugin-plugins-data-server.aggfunctionsmapping.md) > [aggGeoCentroid](./kibana-plugin-plugins-data-server.aggfunctionsmapping.agggeocentroid.md)
+
+## AggFunctionsMapping.aggGeoCentroid property
+
+Signature:
+
+```typescript
+aggGeoCentroid: ReturnType;
+```
diff --git a/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.aggfunctionsmapping.agggeohash.md b/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.aggfunctionsmapping.agggeohash.md
new file mode 100644
index 0000000000000..45aca882bb383
--- /dev/null
+++ b/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.aggfunctionsmapping.agggeohash.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [kibana-plugin-plugins-data-server](./kibana-plugin-plugins-data-server.md) > [AggFunctionsMapping](./kibana-plugin-plugins-data-server.aggfunctionsmapping.md) > [aggGeoHash](./kibana-plugin-plugins-data-server.aggfunctionsmapping.agggeohash.md)
+
+## AggFunctionsMapping.aggGeoHash property
+
+Signature:
+
+```typescript
+aggGeoHash: ReturnType;
+```
diff --git a/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.aggfunctionsmapping.agggeotile.md b/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.aggfunctionsmapping.agggeotile.md
new file mode 100644
index 0000000000000..91322c1dadac3
--- /dev/null
+++ b/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.aggfunctionsmapping.agggeotile.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [kibana-plugin-plugins-data-server](./kibana-plugin-plugins-data-server.md) > [AggFunctionsMapping](./kibana-plugin-plugins-data-server.aggfunctionsmapping.md) > [aggGeoTile](./kibana-plugin-plugins-data-server.aggfunctionsmapping.agggeotile.md)
+
+## AggFunctionsMapping.aggGeoTile property
+
+Signature:
+
+```typescript
+aggGeoTile: ReturnType;
+```
diff --git a/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.aggfunctionsmapping.agghistogram.md b/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.aggfunctionsmapping.agghistogram.md
new file mode 100644
index 0000000000000..b9bf9b549e3e2
--- /dev/null
+++ b/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.aggfunctionsmapping.agghistogram.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [kibana-plugin-plugins-data-server](./kibana-plugin-plugins-data-server.md) > [AggFunctionsMapping](./kibana-plugin-plugins-data-server.aggfunctionsmapping.md) > [aggHistogram](./kibana-plugin-plugins-data-server.aggfunctionsmapping.agghistogram.md)
+
+## AggFunctionsMapping.aggHistogram property
+
+Signature:
+
+```typescript
+aggHistogram: ReturnType;
+```
diff --git a/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.aggfunctionsmapping.aggiprange.md b/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.aggfunctionsmapping.aggiprange.md
new file mode 100644
index 0000000000000..76f9e2c25a6db
--- /dev/null
+++ b/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.aggfunctionsmapping.aggiprange.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [kibana-plugin-plugins-data-server](./kibana-plugin-plugins-data-server.md) > [AggFunctionsMapping](./kibana-plugin-plugins-data-server.aggfunctionsmapping.md) > [aggIpRange](./kibana-plugin-plugins-data-server.aggfunctionsmapping.aggiprange.md)
+
+## AggFunctionsMapping.aggIpRange property
+
+Signature:
+
+```typescript
+aggIpRange: ReturnType;
+```
diff --git a/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.aggfunctionsmapping.aggmax.md b/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.aggfunctionsmapping.aggmax.md
new file mode 100644
index 0000000000000..b4ef663ac002d
--- /dev/null
+++ b/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.aggfunctionsmapping.aggmax.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [kibana-plugin-plugins-data-server](./kibana-plugin-plugins-data-server.md) > [AggFunctionsMapping](./kibana-plugin-plugins-data-server.aggfunctionsmapping.md) > [aggMax](./kibana-plugin-plugins-data-server.aggfunctionsmapping.aggmax.md)
+
+## AggFunctionsMapping.aggMax property
+
+Signature:
+
+```typescript
+aggMax: ReturnType;
+```
diff --git a/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.aggfunctionsmapping.aggmedian.md b/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.aggfunctionsmapping.aggmedian.md
new file mode 100644
index 0000000000000..f84f500d9a24b
--- /dev/null
+++ b/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.aggfunctionsmapping.aggmedian.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [kibana-plugin-plugins-data-server](./kibana-plugin-plugins-data-server.md) > [AggFunctionsMapping](./kibana-plugin-plugins-data-server.aggfunctionsmapping.md) > [aggMedian](./kibana-plugin-plugins-data-server.aggfunctionsmapping.aggmedian.md)
+
+## AggFunctionsMapping.aggMedian property
+
+Signature:
+
+```typescript
+aggMedian: ReturnType;
+```
diff --git a/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.aggfunctionsmapping.aggmin.md b/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.aggfunctionsmapping.aggmin.md
new file mode 100644
index 0000000000000..80e78f9ddead6
--- /dev/null
+++ b/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.aggfunctionsmapping.aggmin.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [kibana-plugin-plugins-data-server](./kibana-plugin-plugins-data-server.md) > [AggFunctionsMapping](./kibana-plugin-plugins-data-server.aggfunctionsmapping.md) > [aggMin](./kibana-plugin-plugins-data-server.aggfunctionsmapping.aggmin.md)
+
+## AggFunctionsMapping.aggMin property
+
+Signature:
+
+```typescript
+aggMin: ReturnType;
+```
diff --git a/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.aggfunctionsmapping.aggmovingavg.md b/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.aggfunctionsmapping.aggmovingavg.md
new file mode 100644
index 0000000000000..c182c56f1dcab
--- /dev/null
+++ b/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.aggfunctionsmapping.aggmovingavg.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [kibana-plugin-plugins-data-server](./kibana-plugin-plugins-data-server.md) > [AggFunctionsMapping](./kibana-plugin-plugins-data-server.aggfunctionsmapping.md) > [aggMovingAvg](./kibana-plugin-plugins-data-server.aggfunctionsmapping.aggmovingavg.md)
+
+## AggFunctionsMapping.aggMovingAvg property
+
+Signature:
+
+```typescript
+aggMovingAvg: ReturnType;
+```
diff --git a/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.aggfunctionsmapping.aggpercentileranks.md b/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.aggfunctionsmapping.aggpercentileranks.md
new file mode 100644
index 0000000000000..bad66bec9682f
--- /dev/null
+++ b/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.aggfunctionsmapping.aggpercentileranks.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [kibana-plugin-plugins-data-server](./kibana-plugin-plugins-data-server.md) > [AggFunctionsMapping](./kibana-plugin-plugins-data-server.aggfunctionsmapping.md) > [aggPercentileRanks](./kibana-plugin-plugins-data-server.aggfunctionsmapping.aggpercentileranks.md)
+
+## AggFunctionsMapping.aggPercentileRanks property
+
+Signature:
+
+```typescript
+aggPercentileRanks: ReturnType;
+```
diff --git a/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.aggfunctionsmapping.aggpercentiles.md b/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.aggfunctionsmapping.aggpercentiles.md
new file mode 100644
index 0000000000000..7ce8f3f46c315
--- /dev/null
+++ b/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.aggfunctionsmapping.aggpercentiles.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [kibana-plugin-plugins-data-server](./kibana-plugin-plugins-data-server.md) > [AggFunctionsMapping](./kibana-plugin-plugins-data-server.aggfunctionsmapping.md) > [aggPercentiles](./kibana-plugin-plugins-data-server.aggfunctionsmapping.aggpercentiles.md)
+
+## AggFunctionsMapping.aggPercentiles property
+
+Signature:
+
+```typescript
+aggPercentiles: ReturnType;
+```
diff --git a/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.aggfunctionsmapping.aggrange.md b/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.aggfunctionsmapping.aggrange.md
new file mode 100644
index 0000000000000..0ff87e450185b
--- /dev/null
+++ b/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.aggfunctionsmapping.aggrange.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [kibana-plugin-plugins-data-server](./kibana-plugin-plugins-data-server.md) > [AggFunctionsMapping](./kibana-plugin-plugins-data-server.aggfunctionsmapping.md) > [aggRange](./kibana-plugin-plugins-data-server.aggfunctionsmapping.aggrange.md)
+
+## AggFunctionsMapping.aggRange property
+
+Signature:
+
+```typescript
+aggRange: ReturnType;
+```
diff --git a/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.aggfunctionsmapping.aggserialdiff.md b/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.aggfunctionsmapping.aggserialdiff.md
new file mode 100644
index 0000000000000..f36ee39b68d1f
--- /dev/null
+++ b/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.aggfunctionsmapping.aggserialdiff.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [kibana-plugin-plugins-data-server](./kibana-plugin-plugins-data-server.md) > [AggFunctionsMapping](./kibana-plugin-plugins-data-server.aggfunctionsmapping.md) > [aggSerialDiff](./kibana-plugin-plugins-data-server.aggfunctionsmapping.aggserialdiff.md)
+
+## AggFunctionsMapping.aggSerialDiff property
+
+Signature:
+
+```typescript
+aggSerialDiff: ReturnType;
+```
diff --git a/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.aggfunctionsmapping.aggsignificantterms.md b/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.aggfunctionsmapping.aggsignificantterms.md
new file mode 100644
index 0000000000000..4e9bfbedf6ec9
--- /dev/null
+++ b/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.aggfunctionsmapping.aggsignificantterms.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [kibana-plugin-plugins-data-server](./kibana-plugin-plugins-data-server.md) > [AggFunctionsMapping](./kibana-plugin-plugins-data-server.aggfunctionsmapping.md) > [aggSignificantTerms](./kibana-plugin-plugins-data-server.aggfunctionsmapping.aggsignificantterms.md)
+
+## AggFunctionsMapping.aggSignificantTerms property
+
+Signature:
+
+```typescript
+aggSignificantTerms: ReturnType;
+```
diff --git a/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.aggfunctionsmapping.aggstddeviation.md b/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.aggfunctionsmapping.aggstddeviation.md
new file mode 100644
index 0000000000000..065a65262027a
--- /dev/null
+++ b/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.aggfunctionsmapping.aggstddeviation.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [kibana-plugin-plugins-data-server](./kibana-plugin-plugins-data-server.md) > [AggFunctionsMapping](./kibana-plugin-plugins-data-server.aggfunctionsmapping.md) > [aggStdDeviation](./kibana-plugin-plugins-data-server.aggfunctionsmapping.aggstddeviation.md)
+
+## AggFunctionsMapping.aggStdDeviation property
+
+Signature:
+
+```typescript
+aggStdDeviation: ReturnType;
+```
diff --git a/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.aggfunctionsmapping.aggsum.md b/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.aggfunctionsmapping.aggsum.md
new file mode 100644
index 0000000000000..35521ab040d8d
--- /dev/null
+++ b/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.aggfunctionsmapping.aggsum.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [kibana-plugin-plugins-data-server](./kibana-plugin-plugins-data-server.md) > [AggFunctionsMapping](./kibana-plugin-plugins-data-server.aggfunctionsmapping.md) > [aggSum](./kibana-plugin-plugins-data-server.aggfunctionsmapping.aggsum.md)
+
+## AggFunctionsMapping.aggSum property
+
+Signature:
+
+```typescript
+aggSum: ReturnType;
+```
diff --git a/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.aggfunctionsmapping.aggterms.md b/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.aggfunctionsmapping.aggterms.md
new file mode 100644
index 0000000000000..efc6218107a13
--- /dev/null
+++ b/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.aggfunctionsmapping.aggterms.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [kibana-plugin-plugins-data-server](./kibana-plugin-plugins-data-server.md) > [AggFunctionsMapping](./kibana-plugin-plugins-data-server.aggfunctionsmapping.md) > [aggTerms](./kibana-plugin-plugins-data-server.aggfunctionsmapping.aggterms.md)
+
+## AggFunctionsMapping.aggTerms property
+
+Signature:
+
+```typescript
+aggTerms: ReturnType;
+```
diff --git a/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.aggfunctionsmapping.aggtophit.md b/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.aggfunctionsmapping.aggtophit.md
new file mode 100644
index 0000000000000..3733486cf2214
--- /dev/null
+++ b/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.aggfunctionsmapping.aggtophit.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [kibana-plugin-plugins-data-server](./kibana-plugin-plugins-data-server.md) > [AggFunctionsMapping](./kibana-plugin-plugins-data-server.aggfunctionsmapping.md) > [aggTopHit](./kibana-plugin-plugins-data-server.aggfunctionsmapping.aggtophit.md)
+
+## AggFunctionsMapping.aggTopHit property
+
+Signature:
+
+```typescript
+aggTopHit: ReturnType;
+```
diff --git a/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.aggfunctionsmapping.md b/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.aggfunctionsmapping.md
new file mode 100644
index 0000000000000..f059bb2914847
--- /dev/null
+++ b/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.aggfunctionsmapping.md
@@ -0,0 +1,51 @@
+
+
+[Home](./index.md) > [kibana-plugin-plugins-data-server](./kibana-plugin-plugins-data-server.md) > [AggFunctionsMapping](./kibana-plugin-plugins-data-server.aggfunctionsmapping.md)
+
+## AggFunctionsMapping interface
+
+A global list of the expression function definitions for each agg type function.
+
+Signature:
+
+```typescript
+export interface AggFunctionsMapping
+```
+
+## Properties
+
+| Property | Type | Description |
+| --- | --- | --- |
+| [aggAvg](./kibana-plugin-plugins-data-server.aggfunctionsmapping.aggavg.md) | ReturnType<typeof aggAvg>
| |
+| [aggBucketAvg](./kibana-plugin-plugins-data-server.aggfunctionsmapping.aggbucketavg.md) | ReturnType<typeof aggBucketAvg>
| |
+| [aggBucketMax](./kibana-plugin-plugins-data-server.aggfunctionsmapping.aggbucketmax.md) | ReturnType<typeof aggBucketMax>
| |
+| [aggBucketMin](./kibana-plugin-plugins-data-server.aggfunctionsmapping.aggbucketmin.md) | ReturnType<typeof aggBucketMin>
| |
+| [aggBucketSum](./kibana-plugin-plugins-data-server.aggfunctionsmapping.aggbucketsum.md) | ReturnType<typeof aggBucketSum>
| |
+| [aggCardinality](./kibana-plugin-plugins-data-server.aggfunctionsmapping.aggcardinality.md) | ReturnType<typeof aggCardinality>
| |
+| [aggCount](./kibana-plugin-plugins-data-server.aggfunctionsmapping.aggcount.md) | ReturnType<typeof aggCount>
| |
+| [aggCumulativeSum](./kibana-plugin-plugins-data-server.aggfunctionsmapping.aggcumulativesum.md) | ReturnType<typeof aggCumulativeSum>
| |
+| [aggDateHistogram](./kibana-plugin-plugins-data-server.aggfunctionsmapping.aggdatehistogram.md) | ReturnType<typeof aggDateHistogram>
| |
+| [aggDateRange](./kibana-plugin-plugins-data-server.aggfunctionsmapping.aggdaterange.md) | ReturnType<typeof aggDateRange>
| |
+| [aggDerivative](./kibana-plugin-plugins-data-server.aggfunctionsmapping.aggderivative.md) | ReturnType<typeof aggDerivative>
| |
+| [aggFilter](./kibana-plugin-plugins-data-server.aggfunctionsmapping.aggfilter.md) | ReturnType<typeof aggFilter>
| |
+| [aggFilters](./kibana-plugin-plugins-data-server.aggfunctionsmapping.aggfilters.md) | ReturnType<typeof aggFilters>
| |
+| [aggGeoBounds](./kibana-plugin-plugins-data-server.aggfunctionsmapping.agggeobounds.md) | ReturnType<typeof aggGeoBounds>
| |
+| [aggGeoCentroid](./kibana-plugin-plugins-data-server.aggfunctionsmapping.agggeocentroid.md) | ReturnType<typeof aggGeoCentroid>
| |
+| [aggGeoHash](./kibana-plugin-plugins-data-server.aggfunctionsmapping.agggeohash.md) | ReturnType<typeof aggGeoHash>
| |
+| [aggGeoTile](./kibana-plugin-plugins-data-server.aggfunctionsmapping.agggeotile.md) | ReturnType<typeof aggGeoTile>
| |
+| [aggHistogram](./kibana-plugin-plugins-data-server.aggfunctionsmapping.agghistogram.md) | ReturnType<typeof aggHistogram>
| |
+| [aggIpRange](./kibana-plugin-plugins-data-server.aggfunctionsmapping.aggiprange.md) | ReturnType<typeof aggIpRange>
| |
+| [aggMax](./kibana-plugin-plugins-data-server.aggfunctionsmapping.aggmax.md) | ReturnType<typeof aggMax>
| |
+| [aggMedian](./kibana-plugin-plugins-data-server.aggfunctionsmapping.aggmedian.md) | ReturnType<typeof aggMedian>
| |
+| [aggMin](./kibana-plugin-plugins-data-server.aggfunctionsmapping.aggmin.md) | ReturnType<typeof aggMin>
| |
+| [aggMovingAvg](./kibana-plugin-plugins-data-server.aggfunctionsmapping.aggmovingavg.md) | ReturnType<typeof aggMovingAvg>
| |
+| [aggPercentileRanks](./kibana-plugin-plugins-data-server.aggfunctionsmapping.aggpercentileranks.md) | ReturnType<typeof aggPercentileRanks>
| |
+| [aggPercentiles](./kibana-plugin-plugins-data-server.aggfunctionsmapping.aggpercentiles.md) | ReturnType<typeof aggPercentiles>
| |
+| [aggRange](./kibana-plugin-plugins-data-server.aggfunctionsmapping.aggrange.md) | ReturnType<typeof aggRange>
| |
+| [aggSerialDiff](./kibana-plugin-plugins-data-server.aggfunctionsmapping.aggserialdiff.md) | ReturnType<typeof aggSerialDiff>
| |
+| [aggSignificantTerms](./kibana-plugin-plugins-data-server.aggfunctionsmapping.aggsignificantterms.md) | ReturnType<typeof aggSignificantTerms>
| |
+| [aggStdDeviation](./kibana-plugin-plugins-data-server.aggfunctionsmapping.aggstddeviation.md) | ReturnType<typeof aggStdDeviation>
| |
+| [aggSum](./kibana-plugin-plugins-data-server.aggfunctionsmapping.aggsum.md) | ReturnType<typeof aggSum>
| |
+| [aggTerms](./kibana-plugin-plugins-data-server.aggfunctionsmapping.aggterms.md) | ReturnType<typeof aggTerms>
| |
+| [aggTopHit](./kibana-plugin-plugins-data-server.aggfunctionsmapping.aggtophit.md) | ReturnType<typeof aggTopHit>
| |
+
diff --git a/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.indexpatternloadexpressionfunctiondefinition.md b/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.indexpatternloadexpressionfunctiondefinition.md
new file mode 100644
index 0000000000000..c54802aa42e25
--- /dev/null
+++ b/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.indexpatternloadexpressionfunctiondefinition.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [kibana-plugin-plugins-data-server](./kibana-plugin-plugins-data-server.md) > [IndexPatternLoadExpressionFunctionDefinition](./kibana-plugin-plugins-data-server.indexpatternloadexpressionfunctiondefinition.md)
+
+## IndexPatternLoadExpressionFunctionDefinition type
+
+Signature:
+
+```typescript
+export declare type IndexPatternLoadExpressionFunctionDefinition = ExpressionFunctionDefinition;
+```
diff --git a/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.md b/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.md
index 55504e01b6c9a..75227575038ab 100644
--- a/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.md
+++ b/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.md
@@ -43,6 +43,7 @@
| Interface | Description |
| --- | --- |
+| [AggFunctionsMapping](./kibana-plugin-plugins-data-server.aggfunctionsmapping.md) | A global list of the expression function definitions for each agg type function. |
| [AggParamOption](./kibana-plugin-plugins-data-server.aggparamoption.md) | |
| [EsQueryConfig](./kibana-plugin-plugins-data-server.esqueryconfig.md) | |
| [FieldDescriptor](./kibana-plugin-plugins-data-server.fielddescriptor.md) | |
@@ -105,6 +106,7 @@
| [IFieldFormatsRegistry](./kibana-plugin-plugins-data-server.ifieldformatsregistry.md) | |
| [IFieldParamType](./kibana-plugin-plugins-data-server.ifieldparamtype.md) | |
| [IMetricAggType](./kibana-plugin-plugins-data-server.imetricaggtype.md) | |
+| [IndexPatternLoadExpressionFunctionDefinition](./kibana-plugin-plugins-data-server.indexpatternloadexpressionfunctiondefinition.md) | |
| [KibanaContext](./kibana-plugin-plugins-data-server.kibanacontext.md) | |
| [ParsedInterval](./kibana-plugin-plugins-data-server.parsedinterval.md) | |
| [Query](./kibana-plugin-plugins-data-server.query.md) | |
diff --git a/src/plugins/data/common/index_patterns/expressions/load_index_pattern.ts b/src/plugins/data/common/index_patterns/expressions/load_index_pattern.ts
index 4c1b56df6e864..c17200ad6baad 100644
--- a/src/plugins/data/common/index_patterns/expressions/load_index_pattern.ts
+++ b/src/plugins/data/common/index_patterns/expressions/load_index_pattern.ts
@@ -23,9 +23,15 @@ import { IndexPatternsContract } from '../index_patterns';
import { IndexPatternSpec } from '..';
const name = 'indexPatternLoad';
+const type = 'index_pattern';
+
+export interface IndexPatternExpressionType {
+ type: typeof type;
+ value: IndexPatternSpec;
+}
type Input = null;
-type Output = Promise<{ type: 'index_pattern'; value: IndexPatternSpec }>;
+type Output = Promise;
interface Arguments {
id: string;
@@ -48,7 +54,7 @@ export const getIndexPatternLoadMeta = (): Omit<
'fn'
> => ({
name,
- type: 'index_pattern',
+ type,
inputTypes: ['null'],
help: i18n.translate('data.functions.indexPatternLoad.help', {
defaultMessage: 'Loads an index pattern',
diff --git a/src/plugins/data/common/index_patterns/index.ts b/src/plugins/data/common/index_patterns/index.ts
index de0078df1b9e4..4ae6e3d87b67e 100644
--- a/src/plugins/data/common/index_patterns/index.ts
+++ b/src/plugins/data/common/index_patterns/index.ts
@@ -22,3 +22,4 @@ export * from './types';
export { IndexPatternsService, IndexPatternsContract } from './index_patterns';
export type { IndexPattern } from './index_patterns';
export * from './errors';
+export * from './expressions';
diff --git a/src/plugins/data/common/search/aggs/agg_config.test.ts b/src/plugins/data/common/search/aggs/agg_config.test.ts
index 9bb47f5cb3575..fcecf531cafd0 100644
--- a/src/plugins/data/common/search/aggs/agg_config.test.ts
+++ b/src/plugins/data/common/search/aggs/agg_config.test.ts
@@ -518,40 +518,45 @@ describe('AggConfig', () => {
const aggConfig = ac.createAggConfig(configStates);
expect(aggConfig.toExpressionAst()).toMatchInlineSnapshot(`
Object {
- "arguments": Object {
- "enabled": Array [
- true,
- ],
- "field": Array [
- "machine.os.keyword",
- ],
- "id": Array [
- "1",
- ],
- "missingBucket": Array [
- false,
- ],
- "missingBucketLabel": Array [
- "Missing",
- ],
- "order": Array [
- "asc",
- ],
- "otherBucket": Array [
- false,
- ],
- "otherBucketLabel": Array [
- "Other",
- ],
- "schema": Array [
- "segment",
- ],
- "size": Array [
- 5,
- ],
- },
- "function": "aggTerms",
- "type": "function",
+ "chain": Array [
+ Object {
+ "arguments": Object {
+ "enabled": Array [
+ true,
+ ],
+ "field": Array [
+ "machine.os.keyword",
+ ],
+ "id": Array [
+ "1",
+ ],
+ "missingBucket": Array [
+ false,
+ ],
+ "missingBucketLabel": Array [
+ "Missing",
+ ],
+ "order": Array [
+ "asc",
+ ],
+ "otherBucket": Array [
+ false,
+ ],
+ "otherBucketLabel": Array [
+ "Other",
+ ],
+ "schema": Array [
+ "segment",
+ ],
+ "size": Array [
+ 5,
+ ],
+ },
+ "function": "aggTerms",
+ "type": "function",
+ },
+ ],
+ "type": "expression",
}
`);
});
@@ -575,7 +580,7 @@ describe('AggConfig', () => {
},
};
const aggConfig = ac.createAggConfig(configStates);
- const aggArg = aggConfig.toExpressionAst()?.arguments.orderAgg;
+ const aggArg = aggConfig.toExpressionAst()?.chain[0].arguments.orderAgg;
expect(aggArg).toMatchInlineSnapshot(`
Array [
Object {
@@ -629,11 +634,16 @@ describe('AggConfig', () => {
range.expressionName = 'aggRange';
const rangesParam = range.params.find((p) => p.name === 'ranges');
rangesParam!.toExpressionAst = (val: any) => ({
- type: 'function',
- function: 'aggRanges',
- arguments: {
- ranges: ['oh hi there!'],
- },
+ type: 'expression',
+ chain: [
+ {
+ type: 'function',
+ function: 'aggRanges',
+ arguments: {
+ ranges: ['oh hi there!'],
+ },
+ },
+ ],
});
const ac = new AggConfigs(indexPattern, [], { typesRegistry });
@@ -645,7 +655,7 @@ describe('AggConfig', () => {
};
const aggConfig = ac.createAggConfig(configStates);
- const ranges = aggConfig.toExpressionAst()!.arguments.ranges;
+ const ranges = aggConfig.toExpressionAst()!.chain[0].arguments.ranges;
expect(ranges).toMatchInlineSnapshot(`
Array [
Object {
@@ -677,9 +687,41 @@ describe('AggConfig', () => {
},
};
const aggConfig = ac.createAggConfig(configStates);
- const json = aggConfig.toExpressionAst()?.arguments.json;
+ const json = aggConfig.toExpressionAst()?.chain[0].arguments.json;
expect(json).toEqual([JSON.stringify(configStates.params.json)]);
});
+
+ it('stringifies arrays only if they are objects', () => {
+ const ac = new AggConfigs(indexPattern, [], { typesRegistry });
+ const configStates = {
+ type: 'range',
+ params: {
+ field: 'bytes',
+ ranges: [
+ { from: 0, to: 1000 },
+ { from: 1001, to: 2000 },
+ { from: 2001, to: 3000 },
+ ],
+ },
+ };
+ const aggConfig = ac.createAggConfig(configStates);
+ const ranges = aggConfig.toExpressionAst()?.chain[0].arguments.ranges;
+ expect(ranges).toEqual([JSON.stringify(configStates.params.ranges)]);
+ });
+
+ it('does not stringify arrays which are not objects', () => {
+ const ac = new AggConfigs(indexPattern, [], { typesRegistry });
+ const configStates = {
+ type: 'percentiles',
+ params: {
+ field: 'bytes',
+ percents: [1, 25, 50, 75, 99],
+ },
+ };
+ const aggConfig = ac.createAggConfig(configStates);
+ const percents = aggConfig.toExpressionAst()?.chain[0].arguments.percents;
+ expect(percents).toEqual([1, 25, 50, 75, 99]);
+ });
});
describe('#makeLabel', () => {
diff --git a/src/plugins/data/common/search/aggs/agg_config.ts b/src/plugins/data/common/search/aggs/agg_config.ts
index 8ca27755e3dda..e4b9c43789bc5 100644
--- a/src/plugins/data/common/search/aggs/agg_config.ts
+++ b/src/plugins/data/common/search/aggs/agg_config.ts
@@ -23,7 +23,7 @@ import { Assign, Ensure } from '@kbn/utility-types';
import { ISearchOptions, ISearchSource } from 'src/plugins/data/public';
import {
- ExpressionAstFunction,
+ ExpressionAstExpression,
ExpressionAstArgument,
SerializedFieldFormat,
} from 'src/plugins/expressions/common';
@@ -316,9 +316,9 @@ export class AggConfig {
}
/**
- * @returns Returns an ExpressionAst representing the function for this agg type.
+ * @returns Returns an ExpressionAst representing the this agg type.
*/
- toExpressionAst(): ExpressionAstFunction | undefined {
+ toExpressionAst(): ExpressionAstExpression | undefined {
const functionName = this.type && this.type.expressionName;
const { type, ...rest } = this.serialize();
if (!functionName || !rest.params) {
@@ -334,13 +334,16 @@ export class AggConfig {
// If the param provides `toExpressionAst`, we call it with the value
const paramExpressionAst = deserializedParam.toExpressionAst(this.getParam(key));
if (paramExpressionAst) {
- acc[key] = [
- {
- type: 'expression',
- chain: [paramExpressionAst],
- },
- ];
+ acc[key] = [paramExpressionAst];
}
+ } else if (value && Array.isArray(value)) {
+ // For array params which don't provide `toExpressionAst`, we stringify
+ // if it's an array of objects, otherwise we keep it as-is
+ const definedValues = value.filter(
+ (v) => typeof v !== 'undefined' && v !== null
+ ) as ExpressionAstArgument[];
+ acc[key] =
+ typeof definedValues[0] === 'object' ? [JSON.stringify(definedValues)] : definedValues;
} else if (typeof value === 'object') {
// For object params which don't provide `toExpressionAst`, we stringify
acc[key] = [JSON.stringify(value)];
@@ -353,15 +356,20 @@ export class AggConfig {
}, {} as Record);
return {
- type: 'function',
- function: functionName,
- arguments: {
- ...params,
- // Expression args which are provided to all functions
- id: [this.id],
- enabled: [this.enabled],
- ...(this.schema ? { schema: [this.schema] } : {}), // schema may be undefined
- },
+ type: 'expression',
+ chain: [
+ {
+ type: 'function',
+ function: functionName,
+ arguments: {
+ ...params,
+ // Expression args which are provided to all functions
+ id: [this.id],
+ enabled: [this.enabled],
+ ...(this.schema ? { schema: [this.schema] } : {}), // schema may be undefined
+ },
+ },
+ ],
};
}
diff --git a/src/plugins/data/common/search/aggs/agg_types.ts b/src/plugins/data/common/search/aggs/agg_types.ts
index 8565de13aed5b..c68b16fd51645 100644
--- a/src/plugins/data/common/search/aggs/agg_types.ts
+++ b/src/plugins/data/common/search/aggs/agg_types.ts
@@ -18,42 +18,12 @@
*/
import { FieldFormatsStartCommon } from '../../field_formats';
-import { BUCKET_TYPES } from './buckets';
-import { METRIC_TYPES } from './metrics';
-import { getCountMetricAgg } from './metrics/count';
-import { getAvgMetricAgg } from './metrics/avg';
-import { getSumMetricAgg } from './metrics/sum';
-import { getMedianMetricAgg } from './metrics/median';
-import { getMinMetricAgg } from './metrics/min';
-import { getMaxMetricAgg } from './metrics/max';
-import { getTopHitMetricAgg } from './metrics/top_hit';
-import { getStdDeviationMetricAgg } from './metrics/std_deviation';
-import { getCardinalityMetricAgg } from './metrics/cardinality';
-import { getPercentilesMetricAgg } from './metrics/percentiles';
-import { getGeoBoundsMetricAgg } from './metrics/geo_bounds';
-import { getGeoCentroidMetricAgg } from './metrics/geo_centroid';
-import { getPercentileRanksMetricAgg } from './metrics/percentile_ranks';
-import { getDerivativeMetricAgg } from './metrics/derivative';
-import { getCumulativeSumMetricAgg } from './metrics/cumulative_sum';
-import { getMovingAvgMetricAgg } from './metrics/moving_avg';
-import { getSerialDiffMetricAgg } from './metrics/serial_diff';
+import * as buckets from './buckets';
+import * as metrics from './metrics';
-import { getDateHistogramBucketAgg, CalculateBoundsFn } from './buckets/date_histogram';
-import { getHistogramBucketAgg } from './buckets/histogram';
-import { getRangeBucketAgg } from './buckets/range';
-import { getDateRangeBucketAgg } from './buckets/date_range';
-import { getIpRangeBucketAgg } from './buckets/ip_range';
-import { getTermsBucketAgg } from './buckets/terms';
-import { getFilterBucketAgg } from './buckets/filter';
-import { getFiltersBucketAgg } from './buckets/filters';
-import { getSignificantTermsBucketAgg } from './buckets/significant_terms';
-import { getGeoHashBucketAgg } from './buckets/geo_hash';
-import { getGeoTitleBucketAgg } from './buckets/geo_tile';
-import { getBucketSumMetricAgg } from './metrics/bucket_sum';
-import { getBucketAvgMetricAgg } from './metrics/bucket_avg';
-import { getBucketMinMetricAgg } from './metrics/bucket_min';
-import { getBucketMaxMetricAgg } from './metrics/bucket_max';
+import { BUCKET_TYPES, CalculateBoundsFn } from './buckets';
+import { METRIC_TYPES } from './metrics';
/** @internal */
export interface AggTypesDependencies {
@@ -63,112 +33,78 @@ export interface AggTypesDependencies {
isDefaultTimezone: () => boolean;
}
+/** @internal */
export const getAggTypes = () => ({
metrics: [
- { name: METRIC_TYPES.COUNT, fn: getCountMetricAgg },
- { name: METRIC_TYPES.AVG, fn: getAvgMetricAgg },
- { name: METRIC_TYPES.SUM, fn: getSumMetricAgg },
- { name: METRIC_TYPES.MEDIAN, fn: getMedianMetricAgg },
- { name: METRIC_TYPES.MIN, fn: getMinMetricAgg },
- { name: METRIC_TYPES.MAX, fn: getMaxMetricAgg },
- { name: METRIC_TYPES.STD_DEV, fn: getStdDeviationMetricAgg },
- { name: METRIC_TYPES.CARDINALITY, fn: getCardinalityMetricAgg },
- { name: METRIC_TYPES.PERCENTILES, fn: getPercentilesMetricAgg },
- { name: METRIC_TYPES.PERCENTILE_RANKS, fn: getPercentileRanksMetricAgg },
- { name: METRIC_TYPES.TOP_HITS, fn: getTopHitMetricAgg },
- { name: METRIC_TYPES.DERIVATIVE, fn: getDerivativeMetricAgg },
- { name: METRIC_TYPES.CUMULATIVE_SUM, fn: getCumulativeSumMetricAgg },
- { name: METRIC_TYPES.MOVING_FN, fn: getMovingAvgMetricAgg },
- { name: METRIC_TYPES.SERIAL_DIFF, fn: getSerialDiffMetricAgg },
- { name: METRIC_TYPES.AVG_BUCKET, fn: getBucketAvgMetricAgg },
- { name: METRIC_TYPES.SUM_BUCKET, fn: getBucketSumMetricAgg },
- { name: METRIC_TYPES.MIN_BUCKET, fn: getBucketMinMetricAgg },
- { name: METRIC_TYPES.MAX_BUCKET, fn: getBucketMaxMetricAgg },
- { name: METRIC_TYPES.GEO_BOUNDS, fn: getGeoBoundsMetricAgg },
- { name: METRIC_TYPES.GEO_CENTROID, fn: getGeoCentroidMetricAgg },
+ { name: METRIC_TYPES.COUNT, fn: metrics.getCountMetricAgg },
+ { name: METRIC_TYPES.AVG, fn: metrics.getAvgMetricAgg },
+ { name: METRIC_TYPES.SUM, fn: metrics.getSumMetricAgg },
+ { name: METRIC_TYPES.MEDIAN, fn: metrics.getMedianMetricAgg },
+ { name: METRIC_TYPES.MIN, fn: metrics.getMinMetricAgg },
+ { name: METRIC_TYPES.MAX, fn: metrics.getMaxMetricAgg },
+ { name: METRIC_TYPES.STD_DEV, fn: metrics.getStdDeviationMetricAgg },
+ { name: METRIC_TYPES.CARDINALITY, fn: metrics.getCardinalityMetricAgg },
+ { name: METRIC_TYPES.PERCENTILES, fn: metrics.getPercentilesMetricAgg },
+ { name: METRIC_TYPES.PERCENTILE_RANKS, fn: metrics.getPercentileRanksMetricAgg },
+ { name: METRIC_TYPES.TOP_HITS, fn: metrics.getTopHitMetricAgg },
+ { name: METRIC_TYPES.DERIVATIVE, fn: metrics.getDerivativeMetricAgg },
+ { name: METRIC_TYPES.CUMULATIVE_SUM, fn: metrics.getCumulativeSumMetricAgg },
+ { name: METRIC_TYPES.MOVING_FN, fn: metrics.getMovingAvgMetricAgg },
+ { name: METRIC_TYPES.SERIAL_DIFF, fn: metrics.getSerialDiffMetricAgg },
+ { name: METRIC_TYPES.AVG_BUCKET, fn: metrics.getBucketAvgMetricAgg },
+ { name: METRIC_TYPES.SUM_BUCKET, fn: metrics.getBucketSumMetricAgg },
+ { name: METRIC_TYPES.MIN_BUCKET, fn: metrics.getBucketMinMetricAgg },
+ { name: METRIC_TYPES.MAX_BUCKET, fn: metrics.getBucketMaxMetricAgg },
+ { name: METRIC_TYPES.GEO_BOUNDS, fn: metrics.getGeoBoundsMetricAgg },
+ { name: METRIC_TYPES.GEO_CENTROID, fn: metrics.getGeoCentroidMetricAgg },
],
buckets: [
- { name: BUCKET_TYPES.DATE_HISTOGRAM, fn: getDateHistogramBucketAgg },
- { name: BUCKET_TYPES.HISTOGRAM, fn: getHistogramBucketAgg },
- { name: BUCKET_TYPES.RANGE, fn: getRangeBucketAgg },
- { name: BUCKET_TYPES.DATE_RANGE, fn: getDateRangeBucketAgg },
- { name: BUCKET_TYPES.IP_RANGE, fn: getIpRangeBucketAgg },
- { name: BUCKET_TYPES.TERMS, fn: getTermsBucketAgg },
- { name: BUCKET_TYPES.FILTER, fn: getFilterBucketAgg },
- { name: BUCKET_TYPES.FILTERS, fn: getFiltersBucketAgg },
- { name: BUCKET_TYPES.SIGNIFICANT_TERMS, fn: getSignificantTermsBucketAgg },
- { name: BUCKET_TYPES.GEOHASH_GRID, fn: getGeoHashBucketAgg },
- { name: BUCKET_TYPES.GEOTILE_GRID, fn: getGeoTitleBucketAgg },
+ { name: BUCKET_TYPES.DATE_HISTOGRAM, fn: buckets.getDateHistogramBucketAgg },
+ { name: BUCKET_TYPES.HISTOGRAM, fn: buckets.getHistogramBucketAgg },
+ { name: BUCKET_TYPES.RANGE, fn: buckets.getRangeBucketAgg },
+ { name: BUCKET_TYPES.DATE_RANGE, fn: buckets.getDateRangeBucketAgg },
+ { name: BUCKET_TYPES.IP_RANGE, fn: buckets.getIpRangeBucketAgg },
+ { name: BUCKET_TYPES.TERMS, fn: buckets.getTermsBucketAgg },
+ { name: BUCKET_TYPES.FILTER, fn: buckets.getFilterBucketAgg },
+ { name: BUCKET_TYPES.FILTERS, fn: buckets.getFiltersBucketAgg },
+ { name: BUCKET_TYPES.SIGNIFICANT_TERMS, fn: buckets.getSignificantTermsBucketAgg },
+ { name: BUCKET_TYPES.GEOHASH_GRID, fn: buckets.getGeoHashBucketAgg },
+ { name: BUCKET_TYPES.GEOTILE_GRID, fn: buckets.getGeoTitleBucketAgg },
],
});
-/** Buckets: **/
-import { aggFilter } from './buckets/filter_fn';
-import { aggFilters } from './buckets/filters_fn';
-import { aggSignificantTerms } from './buckets/significant_terms_fn';
-import { aggIpRange } from './buckets/ip_range_fn';
-import { aggDateRange } from './buckets/date_range_fn';
-import { aggRange } from './buckets/range_fn';
-import { aggGeoTile } from './buckets/geo_tile_fn';
-import { aggGeoHash } from './buckets/geo_hash_fn';
-import { aggHistogram } from './buckets/histogram_fn';
-import { aggDateHistogram } from './buckets/date_histogram_fn';
-import { aggTerms } from './buckets/terms_fn';
-
-/** Metrics: **/
-import { aggAvg } from './metrics/avg_fn';
-import { aggBucketAvg } from './metrics/bucket_avg_fn';
-import { aggBucketMax } from './metrics/bucket_max_fn';
-import { aggBucketMin } from './metrics/bucket_min_fn';
-import { aggBucketSum } from './metrics/bucket_sum_fn';
-import { aggCardinality } from './metrics/cardinality_fn';
-import { aggCount } from './metrics/count_fn';
-import { aggCumulativeSum } from './metrics/cumulative_sum_fn';
-import { aggDerivative } from './metrics/derivative_fn';
-import { aggGeoBounds } from './metrics/geo_bounds_fn';
-import { aggGeoCentroid } from './metrics/geo_centroid_fn';
-import { aggMax } from './metrics/max_fn';
-import { aggMedian } from './metrics/median_fn';
-import { aggMin } from './metrics/min_fn';
-import { aggMovingAvg } from './metrics/moving_avg_fn';
-import { aggPercentileRanks } from './metrics/percentile_ranks_fn';
-import { aggPercentiles } from './metrics/percentiles_fn';
-import { aggSerialDiff } from './metrics/serial_diff_fn';
-import { aggStdDeviation } from './metrics/std_deviation_fn';
-import { aggSum } from './metrics/sum_fn';
-import { aggTopHit } from './metrics/top_hit_fn';
-
+/** @internal */
export const getAggTypesFunctions = () => [
- aggAvg,
- aggBucketAvg,
- aggBucketMax,
- aggBucketMin,
- aggBucketSum,
- aggCardinality,
- aggCount,
- aggCumulativeSum,
- aggDerivative,
- aggGeoBounds,
- aggGeoCentroid,
- aggMax,
- aggMedian,
- aggMin,
- aggMovingAvg,
- aggPercentileRanks,
- aggPercentiles,
- aggSerialDiff,
- aggStdDeviation,
- aggSum,
- aggTopHit,
- aggFilter,
- aggFilters,
- aggSignificantTerms,
- aggIpRange,
- aggDateRange,
- aggRange,
- aggGeoTile,
- aggGeoHash,
- aggDateHistogram,
- aggHistogram,
- aggTerms,
+ buckets.aggFilter,
+ buckets.aggFilters,
+ buckets.aggSignificantTerms,
+ buckets.aggIpRange,
+ buckets.aggDateRange,
+ buckets.aggRange,
+ buckets.aggGeoTile,
+ buckets.aggGeoHash,
+ buckets.aggHistogram,
+ buckets.aggDateHistogram,
+ buckets.aggTerms,
+ metrics.aggAvg,
+ metrics.aggBucketAvg,
+ metrics.aggBucketMax,
+ metrics.aggBucketMin,
+ metrics.aggBucketSum,
+ metrics.aggCardinality,
+ metrics.aggCount,
+ metrics.aggCumulativeSum,
+ metrics.aggDerivative,
+ metrics.aggGeoBounds,
+ metrics.aggGeoCentroid,
+ metrics.aggMax,
+ metrics.aggMedian,
+ metrics.aggMin,
+ metrics.aggMovingAvg,
+ metrics.aggPercentileRanks,
+ metrics.aggPercentiles,
+ metrics.aggSerialDiff,
+ metrics.aggStdDeviation,
+ metrics.aggSum,
+ metrics.aggTopHit,
];
diff --git a/src/plugins/data/common/search/aggs/buckets/date_range.test.ts b/src/plugins/data/common/search/aggs/buckets/date_range.test.ts
index 3cd06cc06545d..02699557c46b1 100644
--- a/src/plugins/data/common/search/aggs/buckets/date_range.test.ts
+++ b/src/plugins/data/common/search/aggs/buckets/date_range.test.ts
@@ -79,22 +79,27 @@ describe('date_range params', () => {
const dateRange = aggConfigs.aggs[0];
expect(dateRange.toExpressionAst()).toMatchInlineSnapshot(`
Object {
- "arguments": Object {
- "enabled": Array [
- true,
- ],
- "id": Array [
- "date_range",
- ],
- "ranges": Array [
- "[{\\"from\\":\\"now-1w/w\\",\\"to\\":\\"now\\"}]",
- ],
- "schema": Array [
- "buckets",
- ],
- },
- "function": "aggDateRange",
- "type": "function",
+ "chain": Array [
+ Object {
+ "arguments": Object {
+ "enabled": Array [
+ true,
+ ],
+ "id": Array [
+ "date_range",
+ ],
+ "ranges": Array [
+ "[{\\"from\\":\\"now-1w/w\\",\\"to\\":\\"now\\"}]",
+ ],
+ "schema": Array [
+ "buckets",
+ ],
+ },
+ "function": "aggDateRange",
+ "type": "function",
+ },
+ ],
+ "type": "expression",
}
`);
});
diff --git a/src/plugins/data/common/search/aggs/buckets/filters.test.ts b/src/plugins/data/common/search/aggs/buckets/filters.test.ts
index 326a3af712e70..f1443deb2f8ea 100644
--- a/src/plugins/data/common/search/aggs/buckets/filters.test.ts
+++ b/src/plugins/data/common/search/aggs/buckets/filters.test.ts
@@ -84,19 +84,24 @@ describe('Filters Agg', () => {
});
expect(aggConfigs.aggs[0].toExpressionAst()).toMatchInlineSnapshot(`
Object {
- "arguments": Object {
- "enabled": Array [
- true,
- ],
- "filters": Array [
- "[{\\"label\\":\\"a\\",\\"input\\":{\\"language\\":\\"lucene\\",\\"query\\":\\"foo\\"}},{\\"label\\":\\"b\\",\\"input\\":{\\"language\\":\\"lucene\\",\\"query\\":\\"status:200\\"}},{\\"label\\":\\"c\\",\\"input\\":{\\"language\\":\\"lucene\\",\\"query\\":\\"status:[400 TO 499] AND (foo OR bar)\\"}}]",
- ],
- "id": Array [
- "test",
- ],
- },
- "function": "aggFilters",
- "type": "function",
+ "chain": Array [
+ Object {
+ "arguments": Object {
+ "enabled": Array [
+ true,
+ ],
+ "filters": Array [
+ "[{\\"label\\":\\"a\\",\\"input\\":{\\"language\\":\\"lucene\\",\\"query\\":\\"foo\\"}},{\\"label\\":\\"b\\",\\"input\\":{\\"language\\":\\"lucene\\",\\"query\\":\\"status:200\\"}},{\\"label\\":\\"c\\",\\"input\\":{\\"language\\":\\"lucene\\",\\"query\\":\\"status:[400 TO 499] AND (foo OR bar)\\"}}]",
+ ],
+ "id": Array [
+ "test",
+ ],
+ },
+ "function": "aggFilters",
+ "type": "function",
+ },
+ ],
+ "type": "expression",
}
`);
});
diff --git a/src/plugins/data/common/search/aggs/buckets/geo_hash.test.ts b/src/plugins/data/common/search/aggs/buckets/geo_hash.test.ts
index 8de6834022639..6002e34235c69 100644
--- a/src/plugins/data/common/search/aggs/buckets/geo_hash.test.ts
+++ b/src/plugins/data/common/search/aggs/buckets/geo_hash.test.ts
@@ -91,34 +91,39 @@ describe('Geohash Agg', () => {
const aggConfigs = getAggConfigs();
expect(aggConfigs.aggs[0].toExpressionAst()).toMatchInlineSnapshot(`
Object {
- "arguments": Object {
- "autoPrecision": Array [
- true,
- ],
- "enabled": Array [
- true,
- ],
- "field": Array [
- "location",
- ],
- "id": Array [
- "geohash_grid",
- ],
- "isFilteredByCollar": Array [
- true,
- ],
- "precision": Array [
- 2,
- ],
- "schema": Array [
- "segment",
- ],
- "useGeocentroid": Array [
- true,
- ],
- },
- "function": "aggGeoHash",
- "type": "function",
+ "chain": Array [
+ Object {
+ "arguments": Object {
+ "autoPrecision": Array [
+ true,
+ ],
+ "enabled": Array [
+ true,
+ ],
+ "field": Array [
+ "location",
+ ],
+ "id": Array [
+ "geohash_grid",
+ ],
+ "isFilteredByCollar": Array [
+ true,
+ ],
+ "precision": Array [
+ 2,
+ ],
+ "schema": Array [
+ "segment",
+ ],
+ "useGeocentroid": Array [
+ true,
+ ],
+ },
+ "function": "aggGeoHash",
+ "type": "function",
+ },
+ ],
+ "type": "expression",
}
`);
});
diff --git a/src/plugins/data/common/search/aggs/buckets/histogram.test.ts b/src/plugins/data/common/search/aggs/buckets/histogram.test.ts
index 1b01b1f235cb5..cbbf3b1ac0e91 100644
--- a/src/plugins/data/common/search/aggs/buckets/histogram.test.ts
+++ b/src/plugins/data/common/search/aggs/buckets/histogram.test.ts
@@ -81,41 +81,73 @@ describe('Histogram Agg', () => {
});
expect(aggConfigs.aggs[0].toExpressionAst()).toMatchInlineSnapshot(`
Object {
- "arguments": Object {
- "enabled": Array [
- true,
- ],
- "extended_bounds": Array [
- "{\\"min\\":\\"\\",\\"max\\":\\"\\"}",
- ],
- "field": Array [
- "field",
- ],
- "has_extended_bounds": Array [
- false,
- ],
- "id": Array [
- "test",
- ],
- "interval": Array [
- "auto",
- ],
- "intervalBase": Array [
- 100,
- ],
- "min_doc_count": Array [
- false,
- ],
- "schema": Array [
- "segment",
- ],
- },
- "function": "aggHistogram",
- "type": "function",
+ "chain": Array [
+ Object {
+ "arguments": Object {
+ "enabled": Array [
+ true,
+ ],
+ "extended_bounds": Array [
+ "{\\"min\\":\\"\\",\\"max\\":\\"\\"}",
+ ],
+ "field": Array [
+ "field",
+ ],
+ "has_extended_bounds": Array [
+ false,
+ ],
+ "id": Array [
+ "test",
+ ],
+ "interval": Array [
+ "auto",
+ ],
+ "intervalBase": Array [
+ 100,
+ ],
+ "min_doc_count": Array [
+ false,
+ ],
+ "schema": Array [
+ "segment",
+ ],
+ },
+ "function": "aggHistogram",
+ "type": "function",
+ },
+ ],
+ "type": "expression",
}
`);
});
+ test('preserves interval type when generating AST', () => {
+ const aggConfigs = getAggConfigs({
+ interval: 1000,
+ field: {
+ name: 'field',
+ },
+ });
+ const aggConfigs2 = getAggConfigs({
+ interval: 'auto',
+ field: {
+ name: 'field',
+ },
+ });
+
+ expect(aggConfigs.aggs[0].toExpressionAst()?.chain[0].arguments.interval)
+ .toMatchInlineSnapshot(`
+ Array [
+ 1000,
+ ]
+ `);
+ expect(aggConfigs2.aggs[0].toExpressionAst()?.chain[0].arguments.interval)
+ .toMatchInlineSnapshot(`
+ Array [
+ "auto",
+ ]
+ `);
+ });
describe('ordered', () => {
let histogramType: BucketAggType;
diff --git a/src/plugins/data/common/search/aggs/buckets/histogram.ts b/src/plugins/data/common/search/aggs/buckets/histogram.ts
index ab0d566b273c7..bfb3c6d6887ad 100644
--- a/src/plugins/data/common/search/aggs/buckets/histogram.ts
+++ b/src/plugins/data/common/search/aggs/buckets/histogram.ts
@@ -49,7 +49,7 @@ export interface IBucketHistogramAggConfig extends IBucketAggConfig {
export interface AggParamsHistogram extends BaseAggParams {
field: string;
- interval: string;
+ interval: number | string;
maxBars?: number;
intervalBase?: number;
min_doc_count?: boolean;
diff --git a/src/plugins/data/common/search/aggs/buckets/histogram_fn.ts b/src/plugins/data/common/search/aggs/buckets/histogram_fn.ts
index 153a7bfc1c592..62dbc7ca8ca45 100644
--- a/src/plugins/data/common/search/aggs/buckets/histogram_fn.ts
+++ b/src/plugins/data/common/search/aggs/buckets/histogram_fn.ts
@@ -72,7 +72,7 @@ export const aggHistogram = (): FunctionDefinition => ({
}),
},
interval: {
- types: ['string'],
+ types: ['number', 'string'],
required: true,
help: i18n.translate('data.search.aggs.buckets.histogram.interval.help', {
defaultMessage: 'Interval to use for this aggregation',
diff --git a/src/plugins/data/common/search/aggs/buckets/index.ts b/src/plugins/data/common/search/aggs/buckets/index.ts
index 04a748bfb1965..990489e5bd52c 100644
--- a/src/plugins/data/common/search/aggs/buckets/index.ts
+++ b/src/plugins/data/common/search/aggs/buckets/index.ts
@@ -20,19 +20,30 @@
export * from './_interval_options';
export * from './bucket_agg_type';
export * from './bucket_agg_types';
-export * from './histogram';
+export * from './date_histogram_fn';
export * from './date_histogram';
+export * from './date_range_fn';
export * from './date_range';
-export * from './range';
+export * from './filter_fn';
export * from './filter';
+export * from './filters_fn';
export * from './filters';
-export * from './geo_tile';
+export * from './geo_hash_fn';
export * from './geo_hash';
+export * from './geo_tile_fn';
+export * from './geo_tile';
+export * from './histogram_fn';
+export * from './histogram';
+export * from './ip_range_fn';
export * from './ip_range';
export * from './lib/cidr_mask';
export * from './lib/date_range';
export * from './lib/ip_range';
+export * from './lib/time_buckets/calc_auto_interval';
export * from './migrate_include_exclude_format';
+export * from './range_fn';
+export * from './range';
+export * from './significant_terms_fn';
export * from './significant_terms';
+export * from './terms_fn';
export * from './terms';
-export * from './lib/time_buckets/calc_auto_interval';
diff --git a/src/plugins/data/common/search/aggs/buckets/lib/histogram_calculate_interval.ts b/src/plugins/data/common/search/aggs/buckets/lib/histogram_calculate_interval.ts
index 313ecf1000f41..ba78aae9a2213 100644
--- a/src/plugins/data/common/search/aggs/buckets/lib/histogram_calculate_interval.ts
+++ b/src/plugins/data/common/search/aggs/buckets/lib/histogram_calculate_interval.ts
@@ -26,7 +26,7 @@ interface IntervalValuesRange {
}
export interface CalculateHistogramIntervalParams {
- interval: string;
+ interval: number | string;
maxBucketsUiSettings: number;
maxBucketsUserInput?: number | '';
esTypes: ES_FIELD_TYPES[];
@@ -124,7 +124,11 @@ export const calculateHistogramInterval = ({
esTypes,
}: CalculateHistogramIntervalParams) => {
const isAuto = isAutoInterval(interval);
- let calculatedInterval = isAuto ? 0 : parseFloat(interval);
+ let calculatedInterval = isAuto
+ ? 0
+ : typeof interval !== 'number'
+ ? parseFloat(interval)
+ : interval;
// should return NaN on non-numeric or invalid values
if (Number.isNaN(calculatedInterval)) {
diff --git a/src/plugins/data/common/search/aggs/buckets/range.test.ts b/src/plugins/data/common/search/aggs/buckets/range.test.ts
index c878e6b81a0ae..2b3732b8cd33c 100644
--- a/src/plugins/data/common/search/aggs/buckets/range.test.ts
+++ b/src/plugins/data/common/search/aggs/buckets/range.test.ts
@@ -70,25 +70,30 @@ describe('Range Agg', () => {
const aggConfigs = getAggConfigs();
expect(aggConfigs.aggs[0].toExpressionAst()).toMatchInlineSnapshot(`
Object {
- "arguments": Object {
- "enabled": Array [
- true,
- ],
- "field": Array [
- "bytes",
- ],
- "id": Array [
- "1",
- ],
- "ranges": Array [
- "[{\\"from\\":0,\\"to\\":1000},{\\"from\\":1000,\\"to\\":2000}]",
- ],
- "schema": Array [
- "segment",
- ],
- },
- "function": "aggRange",
- "type": "function",
+ "chain": Array [
+ Object {
+ "arguments": Object {
+ "enabled": Array [
+ true,
+ ],
+ "field": Array [
+ "bytes",
+ ],
+ "id": Array [
+ "1",
+ ],
+ "ranges": Array [
+ "[{\\"from\\":0,\\"to\\":1000},{\\"from\\":1000,\\"to\\":2000}]",
+ ],
+ "schema": Array [
+ "segment",
+ ],
+ },
+ "function": "aggRange",
+ "type": "function",
+ },
+ ],
+ "type": "expression",
}
`);
});
diff --git a/src/plugins/data/common/search/aggs/buckets/shard_delay.test.ts b/src/plugins/data/common/search/aggs/buckets/shard_delay.test.ts
index 063dec97dadd4..7acb5da295979 100644
--- a/src/plugins/data/common/search/aggs/buckets/shard_delay.test.ts
+++ b/src/plugins/data/common/search/aggs/buckets/shard_delay.test.ts
@@ -64,19 +64,24 @@ describe('Shard Delay Agg', () => {
const aggConfigs = getAggConfigs();
expect(aggConfigs.aggs[0].toExpressionAst()).toMatchInlineSnapshot(`
Object {
- "arguments": Object {
- "delay": Array [
- "5s",
- ],
- "enabled": Array [
- true,
- ],
- "id": Array [
- "1",
- ],
- },
- "function": "aggShardDelay",
- "type": "function",
+ "chain": Array [
+ Object {
+ "arguments": Object {
+ "delay": Array [
+ "5s",
+ ],
+ "enabled": Array [
+ true,
+ ],
+ "id": Array [
+ "1",
+ ],
+ },
+ "function": "aggShardDelay",
+ "type": "function",
+ },
+ ],
+ "type": "expression",
}
`);
});
diff --git a/src/plugins/data/common/search/aggs/buckets/shard_delay.ts b/src/plugins/data/common/search/aggs/buckets/shard_delay.ts
index 2decf5a74bc85..d159de9c52b06 100644
--- a/src/plugins/data/common/search/aggs/buckets/shard_delay.ts
+++ b/src/plugins/data/common/search/aggs/buckets/shard_delay.ts
@@ -24,7 +24,7 @@ import { aggShardDelayFnName } from './shard_delay_fn';
export const SHARD_DELAY_AGG_NAME = 'shard_delay';
export interface AggParamsShardDelay extends BaseAggParams {
- delay?: number;
+ delay?: string;
}
export const getShardDelayBucketAgg = () =>
diff --git a/src/plugins/data/common/search/aggs/buckets/shard_delay_fn.test.ts b/src/plugins/data/common/search/aggs/buckets/shard_delay_fn.test.ts
index b0ebfb005c218..89281490167b3 100644
--- a/src/plugins/data/common/search/aggs/buckets/shard_delay_fn.test.ts
+++ b/src/plugins/data/common/search/aggs/buckets/shard_delay_fn.test.ts
@@ -26,7 +26,7 @@ describe('agg_expression_functions', () => {
test('correctly serializes', () => {
const actual = fn({
- delay: 1000,
+ delay: '1000ms',
});
expect(actual).toMatchInlineSnapshot(`
Object {
@@ -36,7 +36,7 @@ describe('agg_expression_functions', () => {
"id": undefined,
"params": Object {
"customLabel": undefined,
- "delay": 1000,
+ "delay": "1000ms",
"json": undefined,
},
"schema": undefined,
@@ -48,7 +48,7 @@ describe('agg_expression_functions', () => {
test('correctly parses json string argument', () => {
const actual = fn({
- delay: 1000,
+ delay: '1000ms',
json: '{ "foo": true }',
});
@@ -56,7 +56,7 @@ describe('agg_expression_functions', () => {
expect(() => {
fn({
- delay: 1000,
+ delay: '1000ms',
json: '/// intentionally malformed json ///',
});
}).toThrowErrorMatchingInlineSnapshot(`"Unable to parse json argument string"`);
diff --git a/src/plugins/data/common/search/aggs/buckets/shard_delay_fn.ts b/src/plugins/data/common/search/aggs/buckets/shard_delay_fn.ts
index 86de428fa03d7..87f80192ca3cd 100644
--- a/src/plugins/data/common/search/aggs/buckets/shard_delay_fn.ts
+++ b/src/plugins/data/common/search/aggs/buckets/shard_delay_fn.ts
@@ -18,7 +18,6 @@
*/
import { i18n } from '@kbn/i18n';
-import { Assign } from '@kbn/utility-types';
import { ExpressionFunctionDefinition } from 'src/plugins/expressions/common';
import { AggExpressionType, AggConfigSerialized } from '../';
import { getParsedValue } from '../utils/get_parsed_value';
@@ -27,9 +26,7 @@ import { AggParamsShardDelay, SHARD_DELAY_AGG_NAME } from './shard_delay';
export const aggShardDelayFnName = 'aggShardDelay';
type Input = any;
-type AggArgs = AggParamsShardDelay & Pick;
-
-type Arguments = Assign;
+type Arguments = AggParamsShardDelay & Pick;
type Output = AggExpressionType;
type FunctionDefinition = ExpressionFunctionDefinition<
@@ -66,9 +63,9 @@ export const aggShardDelay = (): FunctionDefinition => ({
}),
},
delay: {
- types: ['number'],
+ types: ['string'],
help: i18n.translate('data.search.aggs.buckets.shardDelay.delay.help', {
- defaultMessage: 'Delay in ms between shards to process.',
+ defaultMessage: 'Delay between shards to process. Example: "5s".',
}),
},
json: {
@@ -97,7 +94,6 @@ export const aggShardDelay = (): FunctionDefinition => ({
params: {
...rest,
json: getParsedValue(args, 'json'),
- delay: getParsedValue(args, 'delay'),
},
},
};
diff --git a/src/plugins/data/common/search/aggs/buckets/significant_terms.test.ts b/src/plugins/data/common/search/aggs/buckets/significant_terms.test.ts
index be40ff2267f11..5cf35162eecae 100644
--- a/src/plugins/data/common/search/aggs/buckets/significant_terms.test.ts
+++ b/src/plugins/data/common/search/aggs/buckets/significant_terms.test.ts
@@ -73,25 +73,30 @@ describe('Significant Terms Agg', () => {
});
expect(aggConfigs.aggs[0].toExpressionAst()).toMatchInlineSnapshot(`
Object {
- "arguments": Object {
- "enabled": Array [
- true,
- ],
- "field": Array [
- "FIELD",
- ],
- "id": Array [
- "test",
- ],
- "schema": Array [
- "segment",
- ],
- "size": Array [
- "SIZE",
- ],
- },
- "function": "aggSignificantTerms",
- "type": "function",
+ "chain": Array [
+ Object {
+ "arguments": Object {
+ "enabled": Array [
+ true,
+ ],
+ "field": Array [
+ "FIELD",
+ ],
+ "id": Array [
+ "test",
+ ],
+ "schema": Array [
+ "segment",
+ ],
+ "size": Array [
+ "SIZE",
+ ],
+ },
+ "function": "aggSignificantTerms",
+ "type": "function",
+ },
+ ],
+ "type": "expression",
}
`);
});
diff --git a/src/plugins/data/common/search/aggs/buckets/terms.test.ts b/src/plugins/data/common/search/aggs/buckets/terms.test.ts
index a4116500bec12..0f99695856604 100644
--- a/src/plugins/data/common/search/aggs/buckets/terms.test.ts
+++ b/src/plugins/data/common/search/aggs/buckets/terms.test.ts
@@ -69,59 +69,64 @@ describe('Terms Agg', () => {
});
expect(aggConfigs.aggs[0].toExpressionAst()).toMatchInlineSnapshot(`
Object {
- "arguments": Object {
- "enabled": Array [
- true,
- ],
- "field": Array [
- "field",
- ],
- "id": Array [
- "test",
- ],
- "missingBucket": Array [
- false,
- ],
- "missingBucketLabel": Array [
- "Missing",
- ],
- "order": Array [
- "desc",
- ],
- "orderAgg": Array [
- Object {
- "chain": Array [
+ "chain": Array [
+ Object {
+ "arguments": Object {
+ "enabled": Array [
+ true,
+ ],
+ "field": Array [
+ "field",
+ ],
+ "id": Array [
+ "test",
+ ],
+ "missingBucket": Array [
+ false,
+ ],
+ "missingBucketLabel": Array [
+ "Missing",
+ ],
+ "order": Array [
+ "desc",
+ ],
+ "orderAgg": Array [
Object {
- "arguments": Object {
- "enabled": Array [
- true,
- ],
- "id": Array [
- "test-orderAgg",
- ],
- "schema": Array [
- "orderAgg",
- ],
- },
- "function": "aggCount",
- "type": "function",
+ "chain": Array [
+ Object {
+ "arguments": Object {
+ "enabled": Array [
+ true,
+ ],
+ "id": Array [
+ "test-orderAgg",
+ ],
+ "schema": Array [
+ "orderAgg",
+ ],
+ },
+ "function": "aggCount",
+ "type": "function",
+ },
+ ],
+ "type": "expression",
},
],
- "type": "expression",
+ "otherBucket": Array [
+ false,
+ ],
+ "otherBucketLabel": Array [
+ "Other",
+ ],
+ "size": Array [
+ 5,
+ ],
},
- ],
- "otherBucket": Array [
- false,
- ],
- "otherBucketLabel": Array [
- "Other",
- ],
- "size": Array [
- 5,
- ],
- },
- "function": "aggTerms",
- "type": "function",
+ "function": "aggTerms",
+ "type": "function",
+ },
+ ],
+ "type": "expression",
}
`);
});
diff --git a/src/plugins/data/common/search/aggs/metrics/cumulative_sum.ts b/src/plugins/data/common/search/aggs/metrics/cumulative_sum.ts
index bb0d15782c342..5a60b785343b5 100644
--- a/src/plugins/data/common/search/aggs/metrics/cumulative_sum.ts
+++ b/src/plugins/data/common/search/aggs/metrics/cumulative_sum.ts
@@ -26,7 +26,7 @@ import { METRIC_TYPES } from './metric_agg_types';
import { AggConfigSerialized, BaseAggParams } from '../types';
export interface AggParamsCumulativeSum extends BaseAggParams {
- buckets_path: string;
+ buckets_path?: string;
customMetric?: AggConfigSerialized;
metricAgg?: string;
}
diff --git a/src/plugins/data/common/search/aggs/metrics/cumulative_sum_fn.ts b/src/plugins/data/common/search/aggs/metrics/cumulative_sum_fn.ts
index 43df5301e1a04..040e26125079f 100644
--- a/src/plugins/data/common/search/aggs/metrics/cumulative_sum_fn.ts
+++ b/src/plugins/data/common/search/aggs/metrics/cumulative_sum_fn.ts
@@ -77,7 +77,6 @@ export const aggCumulativeSum = (): FunctionDefinition => ({
},
buckets_path: {
types: ['string'],
- required: true,
help: i18n.translate('data.search.aggs.metrics.cumulative_sum.buckets_path.help', {
defaultMessage: 'Path to the metric of interest',
}),
diff --git a/src/plugins/data/common/search/aggs/metrics/derivative.ts b/src/plugins/data/common/search/aggs/metrics/derivative.ts
index ee32d12e5c85d..036f49a8aef61 100644
--- a/src/plugins/data/common/search/aggs/metrics/derivative.ts
+++ b/src/plugins/data/common/search/aggs/metrics/derivative.ts
@@ -26,7 +26,7 @@ import { METRIC_TYPES } from './metric_agg_types';
import { AggConfigSerialized, BaseAggParams } from '../types';
export interface AggParamsDerivative extends BaseAggParams {
- buckets_path: string;
+ buckets_path?: string;
customMetric?: AggConfigSerialized;
metricAgg?: string;
}
diff --git a/src/plugins/data/common/search/aggs/metrics/derivative_fn.ts b/src/plugins/data/common/search/aggs/metrics/derivative_fn.ts
index 354166ad728ad..93ef0286a0c7e 100644
--- a/src/plugins/data/common/search/aggs/metrics/derivative_fn.ts
+++ b/src/plugins/data/common/search/aggs/metrics/derivative_fn.ts
@@ -77,7 +77,6 @@ export const aggDerivative = (): FunctionDefinition => ({
},
buckets_path: {
types: ['string'],
- required: true,
help: i18n.translate('data.search.aggs.metrics.derivative.buckets_path.help', {
defaultMessage: 'Path to the metric of interest',
}),
diff --git a/src/plugins/data/common/search/aggs/metrics/index.ts b/src/plugins/data/common/search/aggs/metrics/index.ts
index ef7de68b05de9..bd84f5df5b2fb 100644
--- a/src/plugins/data/common/search/aggs/metrics/index.ts
+++ b/src/plugins/data/common/search/aggs/metrics/index.ts
@@ -17,27 +17,49 @@
* under the License.
*/
-export * from './metric_agg_type';
-export * from './metric_agg_types';
+export * from './avg_fn';
+export * from './avg';
+export * from './bucket_avg_fn';
+export * from './bucket_avg';
+export * from './bucket_max_fn';
+export * from './bucket_max';
+export * from './bucket_min_fn';
+export * from './bucket_min';
+export * from './bucket_sum_fn';
+export * from './bucket_sum';
+export * from './cardinality_fn';
+export * from './cardinality';
+export * from './count';
+export * from './count_fn';
+export * from './cumulative_sum_fn';
+export * from './cumulative_sum';
+export * from './derivative_fn';
+export * from './derivative';
+export * from './geo_bounds_fn';
+export * from './geo_bounds';
+export * from './geo_centroid_fn';
+export * from './geo_centroid';
export * from './lib/parent_pipeline_agg_helper';
export * from './lib/sibling_pipeline_agg_helper';
-export { AggParamsAvg } from './avg';
-export { AggParamsCardinality } from './cardinality';
-export { AggParamsGeoBounds } from './geo_bounds';
-export { AggParamsGeoCentroid } from './geo_centroid';
-export { AggParamsMax } from './max';
-export { AggParamsMedian } from './median';
-export { AggParamsMin } from './min';
-export { AggParamsStdDeviation } from './std_deviation';
-export { AggParamsSum } from './sum';
-export { AggParamsBucketAvg } from './bucket_avg';
-export { AggParamsBucketMax } from './bucket_max';
-export { AggParamsBucketMin } from './bucket_min';
-export { AggParamsBucketSum } from './bucket_sum';
-export { AggParamsCumulativeSum } from './cumulative_sum';
-export { AggParamsDerivative } from './derivative';
-export { AggParamsMovingAvg } from './moving_avg';
-export { AggParamsPercentileRanks } from './percentile_ranks';
-export { AggParamsPercentiles } from './percentiles';
-export { AggParamsSerialDiff } from './serial_diff';
-export { AggParamsTopHit } from './top_hit';
+export * from './max_fn';
+export * from './max';
+export * from './median_fn';
+export * from './median';
+export * from './metric_agg_type';
+export * from './metric_agg_types';
+export * from './min_fn';
+export * from './min';
+export * from './moving_avg_fn';
+export * from './moving_avg';
+export * from './percentile_ranks_fn';
+export * from './percentile_ranks';
+export * from './percentiles_fn';
+export * from './percentiles';
+export * from './serial_diff_fn';
+export * from './serial_diff';
+export * from './std_deviation_fn';
+export * from './std_deviation';
+export * from './sum_fn';
+export * from './sum';
+export * from './top_hit_fn';
+export * from './top_hit';
diff --git a/src/plugins/data/common/search/aggs/metrics/median.test.ts b/src/plugins/data/common/search/aggs/metrics/median.test.ts
index 42ea942098c4a..2819da908b054 100644
--- a/src/plugins/data/common/search/aggs/metrics/median.test.ts
+++ b/src/plugins/data/common/search/aggs/metrics/median.test.ts
@@ -87,22 +87,27 @@ describe('AggTypeMetricMedianProvider class', () => {
const agg = aggConfigs.getResponseAggs()[0];
expect(agg.toExpressionAst()).toMatchInlineSnapshot(`
Object {
- "arguments": Object {
- "enabled": Array [
- true,
- ],
- "field": Array [
- "bytes",
- ],
- "id": Array [
- "median",
- ],
- "schema": Array [
- "metric",
- ],
- },
- "function": "aggMedian",
- "type": "function",
+ "chain": Array [
+ Object {
+ "arguments": Object {
+ "enabled": Array [
+ true,
+ ],
+ "field": Array [
+ "bytes",
+ ],
+ "id": Array [
+ "median",
+ ],
+ "schema": Array [
+ "metric",
+ ],
+ },
+ "function": "aggMedian",
+ "type": "function",
+ },
+ ],
+ "type": "expression",
}
`);
});
diff --git a/src/plugins/data/common/search/aggs/metrics/moving_avg.ts b/src/plugins/data/common/search/aggs/metrics/moving_avg.ts
index 60e0f4293cb9e..6c54024458233 100644
--- a/src/plugins/data/common/search/aggs/metrics/moving_avg.ts
+++ b/src/plugins/data/common/search/aggs/metrics/moving_avg.ts
@@ -26,7 +26,7 @@ import { METRIC_TYPES } from './metric_agg_types';
import { AggConfigSerialized, BaseAggParams } from '../types';
export interface AggParamsMovingAvg extends BaseAggParams {
- buckets_path: string;
+ buckets_path?: string;
window?: number;
script?: string;
customMetric?: AggConfigSerialized;
diff --git a/src/plugins/data/common/search/aggs/metrics/moving_avg_fn.ts b/src/plugins/data/common/search/aggs/metrics/moving_avg_fn.ts
index f517becf2bd65..85b7e536e66fc 100644
--- a/src/plugins/data/common/search/aggs/metrics/moving_avg_fn.ts
+++ b/src/plugins/data/common/search/aggs/metrics/moving_avg_fn.ts
@@ -83,7 +83,6 @@ export const aggMovingAvg = (): FunctionDefinition => ({
},
buckets_path: {
types: ['string'],
- required: true,
help: i18n.translate('data.search.aggs.metrics.derivative.buckets_path.help', {
defaultMessage: 'Path to the metric of interest',
}),
diff --git a/src/plugins/data/common/search/aggs/metrics/percentile_ranks.test.ts b/src/plugins/data/common/search/aggs/metrics/percentile_ranks.test.ts
index 9955aeef4e0d2..2750137644c79 100644
--- a/src/plugins/data/common/search/aggs/metrics/percentile_ranks.test.ts
+++ b/src/plugins/data/common/search/aggs/metrics/percentile_ranks.test.ts
@@ -81,54 +81,66 @@ describe('AggTypesMetricsPercentileRanksProvider class', function () {
);
expect(responseAggs[0].toExpressionAst()).toMatchInlineSnapshot(`
Object {
- "arguments": Object {
- "customLabel": Array [
- "my custom field label",
- ],
- "enabled": Array [
- true,
- ],
- "field": Array [
- "bytes",
- ],
- "id": Array [
- "percentile_ranks.5000",
- ],
- "schema": Array [
- "metric",
- ],
- "values": Array [
- "[5000,10000]",
- ],
- },
- "function": "aggPercentileRanks",
- "type": "function",
+ "chain": Array [
+ Object {
+ "arguments": Object {
+ "customLabel": Array [
+ "my custom field label",
+ ],
+ "enabled": Array [
+ true,
+ ],
+ "field": Array [
+ "bytes",
+ ],
+ "id": Array [
+ "percentile_ranks.5000",
+ ],
+ "schema": Array [
+ "metric",
+ ],
+ "values": Array [
+ 5000,
+ 10000,
+ ],
+ },
+ "function": "aggPercentileRanks",
+ "type": "function",
+ },
+ ],
+ "type": "expression",
}
`);
expect(responseAggs[1].toExpressionAst()).toMatchInlineSnapshot(`
Object {
- "arguments": Object {
- "customLabel": Array [
- "my custom field label",
- ],
- "enabled": Array [
- true,
- ],
- "field": Array [
- "bytes",
- ],
- "id": Array [
- "percentile_ranks.10000",
- ],
- "schema": Array [
- "metric",
- ],
- "values": Array [
- "[5000,10000]",
- ],
- },
- "function": "aggPercentileRanks",
- "type": "function",
+ "chain": Array [
+ Object {
+ "arguments": Object {
+ "customLabel": Array [
+ "my custom field label",
+ ],
+ "enabled": Array [
+ true,
+ ],
+ "field": Array [
+ "bytes",
+ ],
+ "id": Array [
+ "percentile_ranks.10000",
+ ],
+ "schema": Array [
+ "metric",
+ ],
+ "values": Array [
+ 5000,
+ 10000,
+ ],
+ },
+ "function": "aggPercentileRanks",
+ "type": "function",
+ },
+ ],
+ "type": "expression",
}
`);
});
diff --git a/src/plugins/data/common/search/aggs/metrics/percentiles.test.ts b/src/plugins/data/common/search/aggs/metrics/percentiles.test.ts
index 78b00a48a9611..05ca3cc22fbb9 100644
--- a/src/plugins/data/common/search/aggs/metrics/percentiles.test.ts
+++ b/src/plugins/data/common/search/aggs/metrics/percentiles.test.ts
@@ -73,28 +73,33 @@ describe('AggTypesMetricsPercentilesProvider class', () => {
);
expect(responseAggs[0].toExpressionAst()).toMatchInlineSnapshot(`
Object {
- "arguments": Object {
- "customLabel": Array [
- "prince",
- ],
- "enabled": Array [
- true,
- ],
- "field": Array [
- "bytes",
- ],
- "id": Array [
- "percentiles.95",
- ],
- "percents": Array [
- "[95]",
- ],
- "schema": Array [
- "metric",
- ],
- },
- "function": "aggPercentiles",
- "type": "function",
+ "chain": Array [
+ Object {
+ "arguments": Object {
+ "customLabel": Array [
+ "prince",
+ ],
+ "enabled": Array [
+ true,
+ ],
+ "field": Array [
+ "bytes",
+ ],
+ "id": Array [
+ "percentiles.95",
+ ],
+ "percents": Array [
+ 95,
+ ],
+ "schema": Array [
+ "metric",
+ ],
+ },
+ "function": "aggPercentiles",
+ "type": "function",
+ },
+ ],
+ "type": "expression",
}
`);
});
diff --git a/src/plugins/data/common/search/aggs/metrics/serial_diff.ts b/src/plugins/data/common/search/aggs/metrics/serial_diff.ts
index 30158a312289f..8f85423e1115e 100644
--- a/src/plugins/data/common/search/aggs/metrics/serial_diff.ts
+++ b/src/plugins/data/common/search/aggs/metrics/serial_diff.ts
@@ -26,7 +26,7 @@ import { METRIC_TYPES } from './metric_agg_types';
import { AggConfigSerialized, BaseAggParams } from '../types';
export interface AggParamsSerialDiff extends BaseAggParams {
- buckets_path: string;
+ buckets_path?: string;
customMetric?: AggConfigSerialized;
metricAgg?: string;
}
diff --git a/src/plugins/data/common/search/aggs/metrics/serial_diff_fn.ts b/src/plugins/data/common/search/aggs/metrics/serial_diff_fn.ts
index 96f82e430a0b4..f3602f5519d5e 100644
--- a/src/plugins/data/common/search/aggs/metrics/serial_diff_fn.ts
+++ b/src/plugins/data/common/search/aggs/metrics/serial_diff_fn.ts
@@ -77,7 +77,6 @@ export const aggSerialDiff = (): FunctionDefinition => ({
},
buckets_path: {
types: ['string'],
- required: true,
help: i18n.translate('data.search.aggs.metrics.serial_diff.buckets_path.help', {
defaultMessage: 'Path to the metric of interest',
}),
diff --git a/src/plugins/data/common/search/aggs/metrics/std_deviation.test.ts b/src/plugins/data/common/search/aggs/metrics/std_deviation.test.ts
index 6ca0c6698376f..541a4c5b3feab 100644
--- a/src/plugins/data/common/search/aggs/metrics/std_deviation.test.ts
+++ b/src/plugins/data/common/search/aggs/metrics/std_deviation.test.ts
@@ -91,19 +91,24 @@ describe('AggTypeMetricStandardDeviationProvider class', () => {
);
expect(responseAggs[0].toExpressionAst()).toMatchInlineSnapshot(`
Object {
- "arguments": Object {
- "enabled": Array [
- true,
- ],
- "id": Array [
- "std_dev.std_lower",
- ],
- "schema": Array [
- "metric",
- ],
- },
- "function": "aggStdDeviation",
- "type": "function",
+ "chain": Array [
+ Object {
+ "arguments": Object {
+ "enabled": Array [
+ true,
+ ],
+ "id": Array [
+ "std_dev.std_lower",
+ ],
+ "schema": Array [
+ "metric",
+ ],
+ },
+ "function": "aggStdDeviation",
+ "type": "function",
+ },
+ ],
+ "type": "expression",
}
`);
});
diff --git a/src/plugins/data/common/search/aggs/metrics/top_hit.test.ts b/src/plugins/data/common/search/aggs/metrics/top_hit.test.ts
index 2fdefa7679e9b..f5434b15204c7 100644
--- a/src/plugins/data/common/search/aggs/metrics/top_hit.test.ts
+++ b/src/plugins/data/common/search/aggs/metrics/top_hit.test.ts
@@ -106,34 +106,39 @@ describe('Top hit metric', () => {
init({ fieldName: 'machine.os' });
expect(aggConfig.toExpressionAst()).toMatchInlineSnapshot(`
Object {
- "arguments": Object {
- "aggregate": Array [
- "concat",
- ],
- "enabled": Array [
- true,
- ],
- "field": Array [
- "machine.os",
- ],
- "id": Array [
- "1",
- ],
- "schema": Array [
- "metric",
- ],
- "size": Array [
- 1,
- ],
- "sortField": Array [
- "machine.os",
- ],
- "sortOrder": Array [
- "desc",
- ],
- },
- "function": "aggTopHit",
- "type": "function",
+ "chain": Array [
+ Object {
+ "arguments": Object {
+ "aggregate": Array [
+ "concat",
+ ],
+ "enabled": Array [
+ true,
+ ],
+ "field": Array [
+ "machine.os",
+ ],
+ "id": Array [
+ "1",
+ ],
+ "schema": Array [
+ "metric",
+ ],
+ "size": Array [
+ 1,
+ ],
+ "sortField": Array [
+ "machine.os",
+ ],
+ "sortOrder": Array [
+ "desc",
+ ],
+ },
+ "function": "aggTopHit",
+ "type": "function",
+ },
+ ],
+ "type": "expression",
}
`);
});
diff --git a/src/plugins/data/common/search/aggs/param_types/base.ts b/src/plugins/data/common/search/aggs/param_types/base.ts
index c0316c974e26f..d1d3bbdcffde2 100644
--- a/src/plugins/data/common/search/aggs/param_types/base.ts
+++ b/src/plugins/data/common/search/aggs/param_types/base.ts
@@ -18,7 +18,7 @@
*/
import { ISearchOptions, ISearchSource } from 'src/plugins/data/public';
-import { ExpressionAstFunction } from 'src/plugins/expressions/common';
+import { ExpressionAstExpression } from 'src/plugins/expressions/common';
import { IAggConfigs } from '../agg_configs';
import { IAggConfig } from '../agg_config';
@@ -37,7 +37,7 @@ export class BaseParamType {
) => void;
serialize: (value: any, aggConfig?: TAggConfig) => any;
deserialize: (value: any, aggConfig?: TAggConfig) => any;
- toExpressionAst?: (value: any) => ExpressionAstFunction | undefined;
+ toExpressionAst?: (value: any) => ExpressionAstExpression | undefined;
options: any[];
valueType?: any;
diff --git a/src/plugins/data/common/search/aggs/types.ts b/src/plugins/data/common/search/aggs/types.ts
index 897b60e91b100..f3ae7d66dca96 100644
--- a/src/plugins/data/common/search/aggs/types.ts
+++ b/src/plugins/data/common/search/aggs/types.ts
@@ -22,46 +22,78 @@ import { DatatableColumn } from 'src/plugins/expressions';
import { IndexPattern } from '../../index_patterns/index_patterns/index_pattern';
import { TimeRange } from '../../query';
import {
- AggConfigSerialized,
+ aggAvg,
+ aggBucketAvg,
+ aggBucketMax,
+ aggBucketMin,
+ aggBucketSum,
+ aggCardinality,
AggConfigs,
- AggParamsRange,
- AggParamsIpRange,
+ AggConfigSerialized,
+ aggCount,
+ aggCumulativeSum,
+ aggDateHistogram,
+ aggDateRange,
+ aggDerivative,
+ aggFilter,
+ aggFilters,
+ aggGeoBounds,
+ aggGeoCentroid,
+ aggGeoHash,
+ aggGeoTile,
+ aggHistogram,
+ aggIpRange,
+ aggMax,
+ aggMedian,
+ aggMin,
+ aggMovingAvg,
+ AggParamsAvg,
+ AggParamsBucketAvg,
+ AggParamsBucketMax,
+ AggParamsBucketMin,
+ AggParamsBucketSum,
+ AggParamsCardinality,
+ AggParamsCumulativeSum,
+ AggParamsDateHistogram,
AggParamsDateRange,
+ AggParamsDerivative,
AggParamsFilter,
AggParamsFilters,
- AggParamsSignificantTerms,
- AggParamsGeoTile,
- AggParamsGeoHash,
- AggParamsTerms,
- AggParamsAvg,
- AggParamsCardinality,
AggParamsGeoBounds,
AggParamsGeoCentroid,
+ AggParamsGeoHash,
+ AggParamsGeoTile,
+ AggParamsHistogram,
+ AggParamsIpRange,
AggParamsMax,
AggParamsMedian,
AggParamsMin,
- AggParamsStdDeviation,
- AggParamsSum,
- AggParamsBucketAvg,
- AggParamsBucketMax,
- AggParamsBucketMin,
- AggParamsBucketSum,
- AggParamsCumulativeSum,
- AggParamsDerivative,
AggParamsMovingAvg,
AggParamsPercentileRanks,
AggParamsPercentiles,
+ AggParamsRange,
AggParamsSerialDiff,
+ AggParamsSignificantTerms,
+ AggParamsStdDeviation,
+ AggParamsSum,
+ AggParamsTerms,
AggParamsTopHit,
- AggParamsHistogram,
- AggParamsDateHistogram,
+ aggPercentileRanks,
+ aggPercentiles,
+ aggRange,
+ aggSerialDiff,
+ aggSignificantTerms,
+ aggStdDeviation,
+ aggSum,
+ aggTerms,
+ aggTopHit,
AggTypesRegistry,
AggTypesRegistrySetup,
AggTypesRegistryStart,
+ BUCKET_TYPES,
CreateAggConfigParams,
getCalculateAutoTimeExpression,
METRIC_TYPES,
- BUCKET_TYPES,
} from './';
export { IAggConfig, AggConfigSerialized } from './agg_config';
@@ -170,3 +202,41 @@ export interface AggParamsMapping {
[METRIC_TYPES.SERIAL_DIFF]: AggParamsSerialDiff;
[METRIC_TYPES.TOP_HITS]: AggParamsTopHit;
}
+
+/**
+ * A global list of the expression function definitions for each agg type function.
+ */
+export interface AggFunctionsMapping {
+ aggFilter: ReturnType;
+ aggFilters: ReturnType;
+ aggSignificantTerms: ReturnType;
+ aggIpRange: ReturnType;
+ aggDateRange: ReturnType;
+ aggRange: ReturnType;
+ aggGeoTile: ReturnType;
+ aggGeoHash: ReturnType;
+ aggHistogram: ReturnType;
+ aggDateHistogram: ReturnType;
+ aggTerms: ReturnType;
+ aggAvg: ReturnType;
+ aggBucketAvg: ReturnType;
+ aggBucketMax: ReturnType;
+ aggBucketMin: ReturnType;
+ aggBucketSum: ReturnType;
+ aggCardinality: ReturnType;
+ aggCount: ReturnType;
+ aggCumulativeSum: ReturnType;
+ aggDerivative: ReturnType;
+ aggGeoBounds: ReturnType;
+ aggGeoCentroid: ReturnType;
+ aggMax: ReturnType;
+ aggMedian: ReturnType;
+ aggMin: ReturnType;
+ aggMovingAvg: ReturnType;
+ aggPercentileRanks: ReturnType;
+ aggPercentiles: ReturnType;
+ aggSerialDiff: ReturnType;
+ aggStdDeviation: ReturnType;
+ aggSum: ReturnType;
+ aggTopHit: ReturnType;
+}
diff --git a/src/plugins/data/common/search/expressions/esaggs/esaggs_fn.ts b/src/plugins/data/common/search/expressions/esaggs/esaggs_fn.ts
index ca1234276f416..6c53a8a09274a 100644
--- a/src/plugins/data/common/search/expressions/esaggs/esaggs_fn.ts
+++ b/src/plugins/data/common/search/expressions/esaggs/esaggs_fn.ts
@@ -26,10 +26,11 @@ import {
} from 'src/plugins/expressions/common';
import { FormatFactory } from '../../../field_formats/utils';
+import { IndexPatternExpressionType } from '../../../index_patterns/expressions';
import { IndexPatternsContract } from '../../../index_patterns/index_patterns';
import { calculateBounds } from '../../../query';
-import { AggsStart } from '../../aggs';
+import { AggsStart, AggExpressionType } from '../../aggs';
import { ISearchStartSearchSource } from '../../search_source';
import { KibanaContext } from '../kibana_context_type';
@@ -42,11 +43,10 @@ type Input = KibanaContext | null;
type Output = Promise;
interface Arguments {
- index: string;
- metricsAtAllLevels: boolean;
- partialRows: boolean;
- includeFormatHints: boolean;
- aggConfigs: string;
+ index: IndexPatternExpressionType;
+ aggs?: AggExpressionType[];
+ metricsAtAllLevels?: boolean;
+ partialRows?: boolean;
timeFields?: string[];
}
@@ -76,33 +76,40 @@ export const getEsaggsMeta: () => Omit
}),
args: {
index: {
- types: ['string'],
- help: '',
+ types: ['index_pattern'],
+ required: true,
+ help: i18n.translate('data.search.functions.esaggs.index.help', {
+ defaultMessage: 'Index pattern retrieved with indexPatternLoad',
+ }),
+ },
+ aggs: {
+ types: ['agg_type'],
+ multi: true,
+ default: [],
+ help: i18n.translate('data.search.functions.esaggs.aggConfigs.help', {
+ defaultMessage: 'List of aggs configured with agg_type functions',
+ }),
},
metricsAtAllLevels: {
types: ['boolean'],
default: false,
- help: '',
+ help: i18n.translate('data.search.functions.esaggs.metricsAtAllLevels.help', {
+ defaultMessage: 'Whether to include columns with metrics for each bucket level',
+ }),
},
partialRows: {
types: ['boolean'],
default: false,
- help: '',
- },
- includeFormatHints: {
- types: ['boolean'],
- default: false,
- help: '',
- },
- aggConfigs: {
- types: ['string'],
- default: '""',
- help: '',
+ help: i18n.translate('data.search.functions.esaggs.partialRows.help', {
+ defaultMessage: 'Whether to return rows that only contain partial data',
+ }),
},
timeFields: {
types: ['string'],
- help: '',
multi: true,
+ help: i18n.translate('data.search.functions.esaggs.timeFields.help', {
+ defaultMessage: 'Provide time fields to get the resolved time ranges for the query',
+ }),
},
},
});
diff --git a/src/plugins/data/common/search/expressions/esaggs/request_handler.test.ts b/src/plugins/data/common/search/expressions/esaggs/request_handler.test.ts
new file mode 100644
index 0000000000000..aba498f720ec1
--- /dev/null
+++ b/src/plugins/data/common/search/expressions/esaggs/request_handler.test.ts
@@ -0,0 +1,193 @@
+/*
+ * Licensed to Elasticsearch B.V. under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Elasticsearch B.V. licenses this file to you under
+ * the Apache License, Version 2.0 (the "License"); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import type { MockedKeys } from '@kbn/utility-types/jest';
+import type { Filter } from '../../../es_query';
+import type { IndexPattern } from '../../../index_patterns';
+import type { IAggConfig, IAggConfigs } from '../../aggs';
+import type { ISearchSource } from '../../search_source';
+import { searchSourceCommonMock } from '../../search_source/mocks';
+
+import { handleRequest, RequestHandlerParams } from './request_handler';
+
+jest.mock('../../tabify', () => ({
+ tabifyAggResponse: jest.fn(),
+}));
+
+import { tabifyAggResponse } from '../../tabify';
+
+describe('esaggs expression function - public', () => {
+ let mockParams: MockedKeys;
+
+ beforeEach(() => {
+ jest.clearAllMocks();
+ mockParams = {
+ abortSignal: (jest.fn() as unknown) as jest.Mocked,
+ addFilters: jest.fn(),
+ aggs: ({
+ aggs: [{ type: { name: 'terms', postFlightRequest: jest.fn().mockResolvedValue({}) } }],
+ setTimeRange: jest.fn(),
+ toDsl: jest.fn().mockReturnValue({ aggs: {} }),
+ onSearchRequestStart: jest.fn(),
+ } as unknown) as jest.Mocked,
+ deserializeFieldFormat: jest.fn(),
+ filters: undefined,
+ indexPattern: ({ id: 'logstash-*' } as unknown) as jest.Mocked,
+ inspectorAdapters: {},
+ metricsAtAllLevels: false,
+ partialRows: false,
+ query: undefined,
+ searchSessionId: 'abc123',
+ searchSourceService: searchSourceCommonMock,
+ timeFields: ['@timestamp', 'utc_time'],
+ timeRange: undefined,
+ };
+ });
+
+ test('should create a new search source instance', async () => {
+ await handleRequest(mockParams);
+ expect(mockParams.searchSourceService.create).toHaveBeenCalledTimes(1);
+ });
+
+ describe('sets the expected fields on search source', () => {
+ let searchSource: MockedKeys;
+
+ beforeEach(async () => {
+ await handleRequest(mockParams);
+ searchSource = await mockParams.searchSourceService.create();
+ });
+
+ test('setField(index)', () => {
+ expect(searchSource.setField).toHaveBeenCalledTimes(5);
+ expect((searchSource.setField as jest.Mock).mock.calls[0]).toEqual([
+ 'index',
+ mockParams.indexPattern,
+ ]);
+ });
+
+ test('setField(size)', () => {
+ expect(searchSource.setField).toHaveBeenCalledTimes(5);
+ expect((searchSource.setField as jest.Mock).mock.calls[1]).toEqual(['size', 0]);
+ });
+
+ test('setField(aggs)', async () => {
+ expect(searchSource.setField).toHaveBeenCalledTimes(5);
+ expect(typeof (searchSource.setField as jest.Mock).mock.calls[2][1]).toBe('function');
+ expect((searchSource.setField as jest.Mock).mock.calls[2][1]()).toEqual(
+ mockParams.aggs.toDsl()
+ );
+ expect(mockParams.aggs.toDsl).toHaveBeenCalledWith(mockParams.metricsAtAllLevels);
+
+ // make sure param is passed through
+ jest.clearAllMocks();
+ await handleRequest({
+ ...mockParams,
+ metricsAtAllLevels: true,
+ });
+ searchSource = await mockParams.searchSourceService.create();
+ (searchSource.setField as jest.Mock).mock.calls[2][1]();
+ expect(mockParams.aggs.toDsl).toHaveBeenCalledWith(true);
+ });
+
+ test('setField(filter)', async () => {
+ expect(searchSource.setField).toHaveBeenCalledTimes(5);
+ expect((searchSource.setField as jest.Mock).mock.calls[3]).toEqual([
+ 'filter',
+ mockParams.filters,
+ ]);
+
+ // make sure param is passed through
+ jest.clearAllMocks();
+ const mockFilters = [{ meta: {} }] as Filter[];
+ await handleRequest({
+ ...mockParams,
+ filters: mockFilters,
+ });
+ searchSource = await mockParams.searchSourceService.create();
+ expect((searchSource.setField as jest.Mock).mock.calls[3]).toEqual(['filter', mockFilters]);
+ });
+
+ test('setField(query)', async () => {
+ expect(searchSource.setField).toHaveBeenCalledTimes(5);
+ expect((searchSource.setField as jest.Mock).mock.calls[4]).toEqual([
+ 'query',
+ mockParams.query,
+ ]);
+
+ // make sure param is passed through
+ jest.clearAllMocks();
+ const mockQuery = { query: 'foo', language: 'bar' };
+ await handleRequest({
+ ...mockParams,
+ query: mockQuery,
+ });
+ searchSource = await mockParams.searchSourceService.create();
+ expect((searchSource.setField as jest.Mock).mock.calls[4]).toEqual(['query', mockQuery]);
+ });
+ });
+
+ test('calls searchSource.fetch', async () => {
+ await handleRequest(mockParams);
+ const searchSource = await mockParams.searchSourceService.create();
+ expect(searchSource.fetch).toHaveBeenCalledWith({
+ abortSignal: mockParams.abortSignal,
+ sessionId: mockParams.searchSessionId,
+ });
+ });
+
+ test('calls agg.postFlightRequest if it exiests', async () => {
+ await handleRequest(mockParams);
+ expect(mockParams.aggs.aggs[0].type.postFlightRequest).toHaveBeenCalledTimes(1);
+
+ // ensure it works if the function doesn't exist
+ jest.clearAllMocks();
+ mockParams.aggs.aggs[0] = ({ type: { name: 'count' } } as unknown) as IAggConfig;
+ expect(async () => await handleRequest(mockParams)).not.toThrowError();
+ });
+
+ test('tabifies response data', async () => {
+ await handleRequest(mockParams);
+ expect(tabifyAggResponse).toHaveBeenCalledWith(
+ mockParams.aggs,
+ {},
+ {
+ metricsAtAllLevels: mockParams.metricsAtAllLevels,
+ partialRows: mockParams.partialRows,
+ timeRange: mockParams.timeRange,
+ }
+ );
+ });
+
+ test('calculates timerange bounds for tabify', async () => {
+ await handleRequest({
+ ...mockParams,
+ timeRange: { from: '2020-12-01', to: '2020-12-31' },
+ });
+ expect((tabifyAggResponse as jest.Mock).mock.calls[0][2].timeRange).toMatchInlineSnapshot(`
+ Object {
+ "from": "2020-12-01T05:00:00.000Z",
+ "timeFields": Array [
+ "@timestamp",
+ "utc_time",
+ ],
+ "to": "2020-12-31T05:00:00.000Z",
+ }
+ `);
+ });
+});
diff --git a/src/plugins/data/common/search/expressions/esaggs/request_handler.ts b/src/plugins/data/common/search/expressions/esaggs/request_handler.ts
index a424ed9e0513d..3c1745409ebcd 100644
--- a/src/plugins/data/common/search/expressions/esaggs/request_handler.ts
+++ b/src/plugins/data/common/search/expressions/esaggs/request_handler.ts
@@ -29,16 +29,15 @@ import {
Query,
TimeRange,
} from '../../../../common';
-import {
- getRequestInspectorStats,
- getResponseInspectorStats,
- IAggConfigs,
- ISearchStartSearchSource,
- tabifyAggResponse,
-} from '../../../../common/search';
import { FormatFactory } from '../../../../common/field_formats/utils';
-import { AddFilters, buildTabularInspectorData } from './build_tabular_inspector_data';
+import { IAggConfigs } from '../../aggs';
+import { ISearchStartSearchSource } from '../../search_source';
+import { tabifyAggResponse } from '../../tabify';
+import { getRequestInspectorStats, getResponseInspectorStats } from '../utils';
+
+import type { AddFilters } from './build_tabular_inspector_data';
+import { buildTabularInspectorData } from './build_tabular_inspector_data';
/** @internal */
export interface RequestHandlerParams {
diff --git a/src/plugins/data/public/index.ts b/src/plugins/data/public/index.ts
index 9eced777a8e36..3dda04d738c96 100644
--- a/src/plugins/data/public/index.ts
+++ b/src/plugins/data/public/index.ts
@@ -273,6 +273,7 @@ export {
TypeMeta as IndexPatternTypeMeta,
AggregationRestrictions as IndexPatternAggRestrictions,
IndexPatternSpec,
+ IndexPatternLoadExpressionFunctionDefinition,
fieldList,
} from '../common';
@@ -331,6 +332,7 @@ export {
AggGroupLabels,
AggGroupName,
AggGroupNames,
+ AggFunctionsMapping,
AggParam,
AggParamOption,
AggParamType,
diff --git a/src/plugins/data/public/public.api.md b/src/plugins/data/public/public.api.md
index df599a7c0188e..179d6c35b3ab6 100644
--- a/src/plugins/data/public/public.api.md
+++ b/src/plugins/data/public/public.api.md
@@ -33,7 +33,7 @@ import { EuiGlobalToastListToast } from '@elastic/eui';
import { EventEmitter } from 'events';
import { ExclusiveUnion } from '@elastic/eui';
import { ExecutionContext } from 'src/plugins/expressions/common';
-import { ExpressionAstFunction } from 'src/plugins/expressions/common';
+import { ExpressionAstExpression } from 'src/plugins/expressions/common';
import { ExpressionFunctionDefinition } from 'src/plugins/expressions/common';
import { ExpressionFunctionDefinition as ExpressionFunctionDefinition_2 } from 'src/plugins/expressions/public';
import { ExpressionsSetup } from 'src/plugins/expressions/public';
@@ -173,7 +173,7 @@ export class AggConfig {
// Warning: (ae-incompatible-release-tags) The symbol "toDsl" is marked as @public, but its signature references "IAggConfigs" which is marked as @internal
toDsl(aggConfigs?: IAggConfigs): any;
// (undocumented)
- toExpressionAst(): ExpressionAstFunction | undefined;
+ toExpressionAst(): ExpressionAstExpression | undefined;
// Warning: (ae-incompatible-release-tags) The symbol "toJSON" is marked as @public, but its signature references "AggConfigSerialized" which is marked as @internal
//
// @deprecated (undocumented)
@@ -267,6 +267,140 @@ export type AggConfigSerialized = Ensure<{
schema?: string;
}, SerializableState>;
+// Warning: (ae-missing-release-tag) "AggFunctionsMapping" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
+//
+// @public
+export interface AggFunctionsMapping {
+ // Warning: (ae-forgotten-export) The symbol "aggAvg" needs to be exported by the entry point index.d.ts
+ //
+ // (undocumented)
+ aggAvg: ReturnType;
+ // Warning: (ae-forgotten-export) The symbol "aggBucketAvg" needs to be exported by the entry point index.d.ts
+ //
+ // (undocumented)
+ aggBucketAvg: ReturnType;
+ // Warning: (ae-forgotten-export) The symbol "aggBucketMax" needs to be exported by the entry point index.d.ts
+ //
+ // (undocumented)
+ aggBucketMax: ReturnType;
+ // Warning: (ae-forgotten-export) The symbol "aggBucketMin" needs to be exported by the entry point index.d.ts
+ //
+ // (undocumented)
+ aggBucketMin: ReturnType;
+ // Warning: (ae-forgotten-export) The symbol "aggBucketSum" needs to be exported by the entry point index.d.ts
+ //
+ // (undocumented)
+ aggBucketSum: ReturnType;
+ // Warning: (ae-forgotten-export) The symbol "aggCardinality" needs to be exported by the entry point index.d.ts
+ //
+ // (undocumented)
+ aggCardinality: ReturnType;
+ // Warning: (ae-forgotten-export) The symbol "aggCount" needs to be exported by the entry point index.d.ts
+ //
+ // (undocumented)
+ aggCount: ReturnType;
+ // Warning: (ae-forgotten-export) The symbol "aggCumulativeSum" needs to be exported by the entry point index.d.ts
+ //
+ // (undocumented)
+ aggCumulativeSum: ReturnType;
+ // Warning: (ae-forgotten-export) The symbol "aggDateHistogram" needs to be exported by the entry point index.d.ts
+ //
+ // (undocumented)
+ aggDateHistogram: ReturnType;
+ // Warning: (ae-forgotten-export) The symbol "aggDateRange" needs to be exported by the entry point index.d.ts
+ //
+ // (undocumented)
+ aggDateRange: ReturnType;
+ // Warning: (ae-forgotten-export) The symbol "aggDerivative" needs to be exported by the entry point index.d.ts
+ //
+ // (undocumented)
+ aggDerivative: ReturnType;
+ // Warning: (ae-forgotten-export) The symbol "aggFilter" needs to be exported by the entry point index.d.ts
+ //
+ // (undocumented)
+ aggFilter: ReturnType;
+ // Warning: (ae-forgotten-export) The symbol "aggFilters" needs to be exported by the entry point index.d.ts
+ //
+ // (undocumented)
+ aggFilters: ReturnType;
+ // Warning: (ae-forgotten-export) The symbol "aggGeoBounds" needs to be exported by the entry point index.d.ts
+ //
+ // (undocumented)
+ aggGeoBounds: ReturnType;
+ // Warning: (ae-forgotten-export) The symbol "aggGeoCentroid" needs to be exported by the entry point index.d.ts
+ //
+ // (undocumented)
+ aggGeoCentroid: ReturnType;
+ // Warning: (ae-forgotten-export) The symbol "aggGeoHash" needs to be exported by the entry point index.d.ts
+ //
+ // (undocumented)
+ aggGeoHash: ReturnType;
+ // Warning: (ae-forgotten-export) The symbol "aggGeoTile" needs to be exported by the entry point index.d.ts
+ //
+ // (undocumented)
+ aggGeoTile: ReturnType;
+ // Warning: (ae-forgotten-export) The symbol "aggHistogram" needs to be exported by the entry point index.d.ts
+ //
+ // (undocumented)
+ aggHistogram: ReturnType;
+ // Warning: (ae-forgotten-export) The symbol "aggIpRange" needs to be exported by the entry point index.d.ts
+ //
+ // (undocumented)
+ aggIpRange: ReturnType;
+ // Warning: (ae-forgotten-export) The symbol "aggMax" needs to be exported by the entry point index.d.ts
+ //
+ // (undocumented)
+ aggMax: ReturnType;
+ // Warning: (ae-forgotten-export) The symbol "aggMedian" needs to be exported by the entry point index.d.ts
+ //
+ // (undocumented)
+ aggMedian: ReturnType;
+ // Warning: (ae-forgotten-export) The symbol "aggMin" needs to be exported by the entry point index.d.ts
+ //
+ // (undocumented)
+ aggMin: ReturnType;
+ // Warning: (ae-forgotten-export) The symbol "aggMovingAvg" needs to be exported by the entry point index.d.ts
+ //
+ // (undocumented)
+ aggMovingAvg: ReturnType;
+ // Warning: (ae-forgotten-export) The symbol "aggPercentileRanks" needs to be exported by the entry point index.d.ts
+ //
+ // (undocumented)
+ aggPercentileRanks: ReturnType;
+ // Warning: (ae-forgotten-export) The symbol "aggPercentiles" needs to be exported by the entry point index.d.ts
+ //
+ // (undocumented)
+ aggPercentiles: ReturnType;
+ // Warning: (ae-forgotten-export) The symbol "aggRange" needs to be exported by the entry point index.d.ts
+ //
+ // (undocumented)
+ aggRange: ReturnType;
+ // Warning: (ae-forgotten-export) The symbol "aggSerialDiff" needs to be exported by the entry point index.d.ts
+ //
+ // (undocumented)
+ aggSerialDiff: ReturnType;
+ // Warning: (ae-forgotten-export) The symbol "aggSignificantTerms" needs to be exported by the entry point index.d.ts
+ //
+ // (undocumented)
+ aggSignificantTerms: ReturnType;
+ // Warning: (ae-forgotten-export) The symbol "aggStdDeviation" needs to be exported by the entry point index.d.ts
+ //
+ // (undocumented)
+ aggStdDeviation: ReturnType;
+ // Warning: (ae-forgotten-export) The symbol "aggSum" needs to be exported by the entry point index.d.ts
+ //
+ // (undocumented)
+ aggSum: ReturnType;
+ // Warning: (ae-forgotten-export) The symbol "aggTerms" needs to be exported by the entry point index.d.ts
+ //
+ // (undocumented)
+ aggTerms: ReturnType;
+ // Warning: (ae-forgotten-export) The symbol "aggTopHit" needs to be exported by the entry point index.d.ts
+ //
+ // (undocumented)
+ aggTopHit: ReturnType;
+}
+
// Warning: (ae-missing-release-tag) "AggGroupLabels" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
@@ -548,7 +682,7 @@ export const ES_SEARCH_STRATEGY = "es";
// Warning: (ae-missing-release-tag) "EsaggsExpressionFunctionDefinition" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
-export type EsaggsExpressionFunctionDefinition = ExpressionFunctionDefinition<'esaggs', Input, Arguments, Output>;
+export type EsaggsExpressionFunctionDefinition = ExpressionFunctionDefinition<'esaggs', Input_34, Arguments_20, Output_34>;
// Warning: (ae-forgotten-export) The symbol "name" needs to be exported by the entry point index.d.ts
// Warning: (ae-forgotten-export) The symbol "Input" needs to be exported by the entry point index.d.ts
@@ -557,7 +691,7 @@ export type EsaggsExpressionFunctionDefinition = ExpressionFunctionDefinition<'e
// Warning: (ae-missing-release-tag) "EsdslExpressionFunctionDefinition" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
-export type EsdslExpressionFunctionDefinition = ExpressionFunctionDefinition_2;
+export type EsdslExpressionFunctionDefinition = ExpressionFunctionDefinition_2;
// Warning: (ae-missing-release-tag) "esFilters" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
@@ -661,7 +795,7 @@ export type EsQuerySortValue = Record;
+export type EsRawResponseExpressionTypeDefinition = ExpressionTypeDefinition;
// Warning: (ae-missing-release-tag) "ExecutionContextSearch" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
@@ -697,7 +831,7 @@ export type ExpressionFunctionKibana = ExpressionFunctionDefinition<'kibana', Ex
// Warning: (ae-missing-release-tag) "ExpressionFunctionKibanaContext" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
-export type ExpressionFunctionKibanaContext = ExpressionFunctionDefinition<'kibana_context', KibanaContext | null, Arguments_2, Promise, ExecutionContext>;
+export type ExpressionFunctionKibanaContext = ExpressionFunctionDefinition<'kibana_context', KibanaContext | null, Arguments_21, Promise, ExecutionContext>;
// Warning: (ae-missing-release-tag) "ExpressionValueSearchContext" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
@@ -1333,6 +1467,15 @@ export class IndexPatternField implements IFieldType {
get visualizable(): boolean;
}
+// Warning: (ae-forgotten-export) The symbol "name" needs to be exported by the entry point index.d.ts
+// Warning: (ae-forgotten-export) The symbol "Input" needs to be exported by the entry point index.d.ts
+// Warning: (ae-forgotten-export) The symbol "Arguments" needs to be exported by the entry point index.d.ts
+// Warning: (ae-forgotten-export) The symbol "Output" needs to be exported by the entry point index.d.ts
+// Warning: (ae-missing-release-tag) "IndexPatternLoadExpressionFunctionDefinition" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
+//
+// @public (undocumented)
+export type IndexPatternLoadExpressionFunctionDefinition = ExpressionFunctionDefinition;
+
// Warning: (ae-missing-release-tag) "indexPatterns" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
@@ -2415,7 +2558,7 @@ export const UI_SETTINGS: {
// src/plugins/data/common/es_query/filters/phrases_filter.ts:31:3 - (ae-forgotten-export) The symbol "PhrasesFilterMeta" needs to be exported by the entry point index.d.ts
// src/plugins/data/common/index_patterns/index_patterns/index_pattern.ts:64:5 - (ae-forgotten-export) The symbol "FormatFieldFn" needs to be exported by the entry point index.d.ts
// src/plugins/data/common/index_patterns/index_patterns/index_pattern.ts:128:7 - (ae-forgotten-export) The symbol "FieldAttrSet" needs to be exported by the entry point index.d.ts
-// src/plugins/data/common/search/aggs/types.ts:113:51 - (ae-forgotten-export) The symbol "AggTypesRegistryStart" needs to be exported by the entry point index.d.ts
+// src/plugins/data/common/search/aggs/types.ts:145:51 - (ae-forgotten-export) The symbol "AggTypesRegistryStart" needs to be exported by the entry point index.d.ts
// src/plugins/data/common/search/search_source/search_source.ts:197:7 - (ae-forgotten-export) The symbol "SearchFieldValue" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/field_formats/field_formats_service.ts:67:3 - (ae-forgotten-export) The symbol "FormatFactory" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:66:23 - (ae-forgotten-export) The symbol "FILTERS" needs to be exported by the entry point index.d.ts
@@ -2449,21 +2592,21 @@ export const UI_SETTINGS: {
// src/plugins/data/public/index.ts:245:27 - (ae-forgotten-export) The symbol "validateIndexPattern" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:245:27 - (ae-forgotten-export) The symbol "flattenHitWrapper" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:245:27 - (ae-forgotten-export) The symbol "formatHitProvider" needs to be exported by the entry point index.d.ts
-// src/plugins/data/public/index.ts:407:20 - (ae-forgotten-export) The symbol "getRequestInspectorStats" needs to be exported by the entry point index.d.ts
-// src/plugins/data/public/index.ts:407:20 - (ae-forgotten-export) The symbol "getResponseInspectorStats" needs to be exported by the entry point index.d.ts
-// src/plugins/data/public/index.ts:407:20 - (ae-forgotten-export) The symbol "tabifyAggResponse" needs to be exported by the entry point index.d.ts
-// src/plugins/data/public/index.ts:407:20 - (ae-forgotten-export) The symbol "tabifyGetColumns" needs to be exported by the entry point index.d.ts
-// src/plugins/data/public/index.ts:409:1 - (ae-forgotten-export) The symbol "CidrMask" needs to be exported by the entry point index.d.ts
-// src/plugins/data/public/index.ts:410:1 - (ae-forgotten-export) The symbol "dateHistogramInterval" needs to be exported by the entry point index.d.ts
-// src/plugins/data/public/index.ts:419:1 - (ae-forgotten-export) The symbol "InvalidEsCalendarIntervalError" needs to be exported by the entry point index.d.ts
-// src/plugins/data/public/index.ts:420:1 - (ae-forgotten-export) The symbol "InvalidEsIntervalFormatError" needs to be exported by the entry point index.d.ts
-// src/plugins/data/public/index.ts:421:1 - (ae-forgotten-export) The symbol "Ipv4Address" needs to be exported by the entry point index.d.ts
-// src/plugins/data/public/index.ts:422:1 - (ae-forgotten-export) The symbol "isDateHistogramBucketAggConfig" needs to be exported by the entry point index.d.ts
-// src/plugins/data/public/index.ts:426:1 - (ae-forgotten-export) The symbol "isValidEsInterval" needs to be exported by the entry point index.d.ts
-// src/plugins/data/public/index.ts:427:1 - (ae-forgotten-export) The symbol "isValidInterval" needs to be exported by the entry point index.d.ts
-// src/plugins/data/public/index.ts:430:1 - (ae-forgotten-export) The symbol "parseInterval" needs to be exported by the entry point index.d.ts
-// src/plugins/data/public/index.ts:431:1 - (ae-forgotten-export) The symbol "propFilter" needs to be exported by the entry point index.d.ts
-// src/plugins/data/public/index.ts:434:1 - (ae-forgotten-export) The symbol "toAbsoluteDates" needs to be exported by the entry point index.d.ts
+// src/plugins/data/public/index.ts:409:20 - (ae-forgotten-export) The symbol "getRequestInspectorStats" needs to be exported by the entry point index.d.ts
+// src/plugins/data/public/index.ts:409:20 - (ae-forgotten-export) The symbol "getResponseInspectorStats" needs to be exported by the entry point index.d.ts
+// src/plugins/data/public/index.ts:409:20 - (ae-forgotten-export) The symbol "tabifyAggResponse" needs to be exported by the entry point index.d.ts
+// src/plugins/data/public/index.ts:409:20 - (ae-forgotten-export) The symbol "tabifyGetColumns" needs to be exported by the entry point index.d.ts
+// src/plugins/data/public/index.ts:411:1 - (ae-forgotten-export) The symbol "CidrMask" needs to be exported by the entry point index.d.ts
+// src/plugins/data/public/index.ts:412:1 - (ae-forgotten-export) The symbol "dateHistogramInterval" needs to be exported by the entry point index.d.ts
+// src/plugins/data/public/index.ts:421:1 - (ae-forgotten-export) The symbol "InvalidEsCalendarIntervalError" needs to be exported by the entry point index.d.ts
+// src/plugins/data/public/index.ts:422:1 - (ae-forgotten-export) The symbol "InvalidEsIntervalFormatError" needs to be exported by the entry point index.d.ts
+// src/plugins/data/public/index.ts:423:1 - (ae-forgotten-export) The symbol "Ipv4Address" needs to be exported by the entry point index.d.ts
+// src/plugins/data/public/index.ts:424:1 - (ae-forgotten-export) The symbol "isDateHistogramBucketAggConfig" needs to be exported by the entry point index.d.ts
+// src/plugins/data/public/index.ts:428:1 - (ae-forgotten-export) The symbol "isValidEsInterval" needs to be exported by the entry point index.d.ts
+// src/plugins/data/public/index.ts:429:1 - (ae-forgotten-export) The symbol "isValidInterval" needs to be exported by the entry point index.d.ts
+// src/plugins/data/public/index.ts:432:1 - (ae-forgotten-export) The symbol "parseInterval" needs to be exported by the entry point index.d.ts
+// src/plugins/data/public/index.ts:433:1 - (ae-forgotten-export) The symbol "propFilter" needs to be exported by the entry point index.d.ts
+// src/plugins/data/public/index.ts:436:1 - (ae-forgotten-export) The symbol "toAbsoluteDates" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/query/state_sync/connect_to_query_state.ts:45:5 - (ae-forgotten-export) The symbol "FilterStateStore" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/search/session/session_service.ts:46:5 - (ae-forgotten-export) The symbol "UrlGeneratorStateMapping" needs to be exported by the entry point index.d.ts
diff --git a/src/plugins/data/public/search/expressions/esaggs.test.ts b/src/plugins/data/public/search/expressions/esaggs.test.ts
new file mode 100644
index 0000000000000..10ed22c861188
--- /dev/null
+++ b/src/plugins/data/public/search/expressions/esaggs.test.ts
@@ -0,0 +1,155 @@
+/*
+ * Licensed to Elasticsearch B.V. under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Elasticsearch B.V. licenses this file to you under
+ * the Apache License, Version 2.0 (the "License"); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import type { MockedKeys } from '@kbn/utility-types/jest';
+import type { ExecutionContext } from 'src/plugins/expressions/public';
+import type { IndexPatternsContract } from '../../../common/index_patterns/index_patterns';
+import type {
+ ISearchStartSearchSource,
+ KibanaContext,
+ EsaggsStartDependencies,
+ EsaggsExpressionFunctionDefinition,
+} from '../../../common/search';
+import type { AggsStart } from '../aggs/types';
+import { getFunctionDefinition } from './esaggs';
+
+jest.mock('../../../common/search/expressions', () => ({
+ getEsaggsMeta: jest.fn().mockReturnValue({ name: 'esaggs' }),
+ handleEsaggsRequest: jest.fn().mockResolvedValue({}),
+}));
+
+import { getEsaggsMeta, handleEsaggsRequest } from '../../../common/search/expressions';
+
+describe('esaggs expression function - public', () => {
+ let getStartDependencies: () => Promise>;
+ let startDependencies: MockedKeys;
+ let mockHandlers: MockedKeys;
+ let definition: () => EsaggsExpressionFunctionDefinition;
+ const args = {
+ index: {
+ type: 'index_pattern' as 'index_pattern',
+ value: { title: 'logstash-*' },
+ },
+ aggs: [
+ {
+ type: 'agg_type' as 'agg_type',
+ value: { type: 'count' },
+ },
+ {
+ type: 'agg_type' as 'agg_type',
+ value: { type: 'avg', params: { field: 'bytes' } },
+ },
+ ],
+ metricsAtAllLevels: true,
+ partialRows: false,
+ timeFields: ['@timestamp', 'utc_time'],
+ };
+
+ beforeEach(() => {
+ jest.clearAllMocks();
+ mockHandlers = {
+ abortSignal: (jest.fn() as unknown) as jest.Mocked,
+ getSearchContext: jest.fn(),
+ getSearchSessionId: jest.fn().mockReturnValue('abc123'),
+ inspectorAdapters: jest.fn(),
+ variables: {},
+ types: {},
+ };
+ startDependencies = {
+ addFilters: jest.fn(),
+ aggs: ({
+ createAggConfigs: jest.fn().mockReturnValue({ foo: 'bar' }),
+ } as unknown) as jest.Mocked,
+ deserializeFieldFormat: jest.fn().mockImplementation((f: any) => f),
+ indexPatterns: ({
+ create: jest.fn().mockResolvedValue({}),
+ } as unknown) as jest.Mocked,
+ searchSource: ({} as unknown) as jest.Mocked,
+ };
+ getStartDependencies = jest.fn().mockResolvedValue(startDependencies);
+ definition = getFunctionDefinition({ getStartDependencies });
+ });
+
+ test('calls indexPatterns.create with the values provided by the subexpression arg', async () => {
+ await definition().fn(null, args, mockHandlers);
+
+ expect(startDependencies.indexPatterns.create).toHaveBeenCalledWith(args.index.value, true);
+ });
+
+ test('calls aggs.createAggConfigs with the values provided by the subexpression arg', async () => {
+ await definition().fn(null, args, mockHandlers);
+
+ expect(startDependencies.aggs.createAggConfigs).toHaveBeenCalledWith(
+ {},
+ args.aggs.map((agg) => agg.value)
+ );
+ });
+
+ test('calls getEsaggsMeta to retrieve meta', () => {
+ const result = definition();
+
+ expect(getEsaggsMeta).toHaveBeenCalledTimes(1);
+ expect(result.name).toBe('esaggs');
+ });
+
+ test('calls handleEsaggsRequest with all of the right dependencies', async () => {
+ await definition().fn(null, args, mockHandlers);
+
+ expect(handleEsaggsRequest).toHaveBeenCalledWith(null, args, {
+ abortSignal: mockHandlers.abortSignal,
+ addFilters: startDependencies.addFilters,
+ aggs: { foo: 'bar' },
+ deserializeFieldFormat: startDependencies.deserializeFieldFormat,
+ filters: undefined,
+ indexPattern: {},
+ inspectorAdapters: mockHandlers.inspectorAdapters,
+ metricsAtAllLevels: args.metricsAtAllLevels,
+ partialRows: args.partialRows,
+ query: undefined,
+ searchSessionId: 'abc123',
+ searchSourceService: startDependencies.searchSource,
+ timeFields: args.timeFields,
+ timeRange: undefined,
+ });
+ });
+
+ test('passes input to handleEsaggsRequest if it is available', async () => {
+ const input = {
+ type: 'kibana_context' as 'kibana_context',
+ filters: [{ $state: {}, meta: {}, query: {} }],
+ query: {
+ query: 'hiya',
+ language: 'painless',
+ },
+ timeRange: { from: 'a', to: 'b' },
+ } as KibanaContext;
+
+ await definition().fn(input, args, mockHandlers);
+
+ expect(handleEsaggsRequest).toHaveBeenCalledWith(
+ input,
+ args,
+ expect.objectContaining({
+ filters: input.filters,
+ query: input.query,
+ timeRange: input.timeRange,
+ })
+ );
+ });
+});
diff --git a/src/plugins/data/public/search/expressions/esaggs.ts b/src/plugins/data/public/search/expressions/esaggs.ts
index efb31423afcdf..4a078bf9b2e55 100644
--- a/src/plugins/data/public/search/expressions/esaggs.ts
+++ b/src/plugins/data/public/search/expressions/esaggs.ts
@@ -56,9 +56,11 @@ export function getFunctionDefinition({
searchSource,
} = await getStartDependencies();
- const aggConfigsState = JSON.parse(args.aggConfigs);
- const indexPattern = await indexPatterns.get(args.index);
- const aggConfigs = aggs.createAggConfigs(indexPattern, aggConfigsState);
+ const indexPattern = await indexPatterns.create(args.index.value, true);
+ const aggConfigs = aggs.createAggConfigs(
+ indexPattern,
+ args.aggs!.map((agg) => agg.value)
+ );
return await handleEsaggsRequest(input, args, {
abortSignal: (abortSignal as unknown) as AbortSignal,
diff --git a/src/plugins/data/server/index.ts b/src/plugins/data/server/index.ts
index 9c483de95df46..b42619500525b 100644
--- a/src/plugins/data/server/index.ts
+++ b/src/plugins/data/server/index.ts
@@ -156,6 +156,7 @@ export {
IndexPatternAttributes,
UI_SETTINGS,
IndexPattern,
+ IndexPatternLoadExpressionFunctionDefinition,
} from '../common';
/**
@@ -196,6 +197,7 @@ export {
AggGroupLabels,
AggGroupName,
AggGroupNames,
+ AggFunctionsMapping,
AggParam,
AggParamOption,
AggParamType,
diff --git a/src/plugins/data/server/search/expressions/esaggs.test.ts b/src/plugins/data/server/search/expressions/esaggs.test.ts
new file mode 100644
index 0000000000000..91c897e194d70
--- /dev/null
+++ b/src/plugins/data/server/search/expressions/esaggs.test.ts
@@ -0,0 +1,161 @@
+/*
+ * Licensed to Elasticsearch B.V. under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Elasticsearch B.V. licenses this file to you under
+ * the Apache License, Version 2.0 (the "License"); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import type { MockedKeys } from '@kbn/utility-types/jest';
+import { KibanaRequest } from 'src/core/server';
+import type { ExecutionContext } from 'src/plugins/expressions/server';
+import type { IndexPatternsContract } from '../../../common/index_patterns/index_patterns';
+import type {
+ AggsCommonStart,
+ ISearchStartSearchSource,
+ KibanaContext,
+ EsaggsStartDependencies,
+ EsaggsExpressionFunctionDefinition,
+} from '../../../common/search';
+import { getFunctionDefinition } from './esaggs';
+
+jest.mock('../../../common/search/expressions', () => ({
+ getEsaggsMeta: jest.fn().mockReturnValue({ name: 'esaggs' }),
+ handleEsaggsRequest: jest.fn().mockResolvedValue({}),
+}));
+
+import { getEsaggsMeta, handleEsaggsRequest } from '../../../common/search/expressions';
+
+describe('esaggs expression function - server', () => {
+ let getStartDependencies: () => Promise>;
+ let startDependencies: MockedKeys;
+ let mockHandlers: MockedKeys;
+ let definition: () => EsaggsExpressionFunctionDefinition;
+ const args = {
+ index: {
+ type: 'index_pattern' as 'index_pattern',
+ value: { title: 'logstash-*' },
+ },
+ aggs: [
+ {
+ type: 'agg_type' as 'agg_type',
+ value: { type: 'count' },
+ },
+ {
+ type: 'agg_type' as 'agg_type',
+ value: { type: 'avg', params: { field: 'bytes' } },
+ },
+ ],
+ metricsAtAllLevels: true,
+ partialRows: false,
+ timeFields: ['@timestamp', 'utc_time'],
+ };
+
+ beforeEach(() => {
+ jest.clearAllMocks();
+ mockHandlers = {
+ abortSignal: (jest.fn() as unknown) as jest.Mocked,
+ getKibanaRequest: jest.fn().mockReturnValue({ id: 'hi' } as KibanaRequest),
+ getSearchContext: jest.fn(),
+ getSearchSessionId: jest.fn().mockReturnValue('abc123'),
+ inspectorAdapters: jest.fn(),
+ variables: {},
+ types: {},
+ };
+ startDependencies = {
+ aggs: ({
+ createAggConfigs: jest.fn().mockReturnValue({ foo: 'bar' }),
+ } as unknown) as jest.Mocked,
+ deserializeFieldFormat: jest.fn().mockImplementation((f: any) => f),
+ indexPatterns: ({
+ create: jest.fn().mockResolvedValue({}),
+ } as unknown) as jest.Mocked,
+ searchSource: ({} as unknown) as jest.Mocked,
+ };
+ getStartDependencies = jest.fn().mockResolvedValue(startDependencies);
+ definition = getFunctionDefinition({ getStartDependencies });
+ });
+
+ test('calls getStartDependencies with the KibanaRequest', async () => {
+ await definition().fn(null, args, mockHandlers);
+
+ expect(getStartDependencies).toHaveBeenCalledWith({ id: 'hi' });
+ });
+
+ test('calls indexPatterns.create with the values provided by the subexpression arg', async () => {
+ await definition().fn(null, args, mockHandlers);
+
+ expect(startDependencies.indexPatterns.create).toHaveBeenCalledWith(args.index.value, true);
+ });
+
+ test('calls aggs.createAggConfigs with the values provided by the subexpression arg', async () => {
+ await definition().fn(null, args, mockHandlers);
+
+ expect(startDependencies.aggs.createAggConfigs).toHaveBeenCalledWith(
+ {},
+ args.aggs.map((agg) => agg.value)
+ );
+ });
+
+ test('calls getEsaggsMeta to retrieve meta', () => {
+ const result = definition();
+
+ expect(getEsaggsMeta).toHaveBeenCalledTimes(1);
+ expect(result.name).toBe('esaggs');
+ });
+
+ test('calls handleEsaggsRequest with all of the right dependencies', async () => {
+ await definition().fn(null, args, mockHandlers);
+
+ expect(handleEsaggsRequest).toHaveBeenCalledWith(null, args, {
+ abortSignal: mockHandlers.abortSignal,
+ aggs: { foo: 'bar' },
+ deserializeFieldFormat: startDependencies.deserializeFieldFormat,
+ filters: undefined,
+ indexPattern: {},
+ inspectorAdapters: mockHandlers.inspectorAdapters,
+ metricsAtAllLevels: args.metricsAtAllLevels,
+ partialRows: args.partialRows,
+ query: undefined,
+ searchSessionId: 'abc123',
+ searchSourceService: startDependencies.searchSource,
+ timeFields: args.timeFields,
+ timeRange: undefined,
+ });
+ });
+
+ test('passes input to handleEsaggsRequest if it is available', async () => {
+ const input = {
+ type: 'kibana_context' as 'kibana_context',
+ filters: [{ $state: {}, meta: {}, query: {} }],
+ query: {
+ query: 'hiya',
+ language: 'painless',
+ },
+ timeRange: { from: 'a', to: 'b' },
+ } as KibanaContext;
+
+ await definition().fn(input, args, mockHandlers);
+
+ expect(handleEsaggsRequest).toHaveBeenCalledWith(
+ input,
+ args,
+ expect.objectContaining({
+ filters: input.filters,
+ query: input.query,
+ timeRange: input.timeRange,
+ })
+ );
+ });
+});
diff --git a/src/plugins/data/server/search/expressions/esaggs.ts b/src/plugins/data/server/search/expressions/esaggs.ts
index 04cfcd1eef043..b8cce165c4308 100644
--- a/src/plugins/data/server/search/expressions/esaggs.ts
+++ b/src/plugins/data/server/search/expressions/esaggs.ts
@@ -71,9 +71,11 @@ export function getFunctionDefinition({
searchSource,
} = await getStartDependencies(kibanaRequest);
- const aggConfigsState = JSON.parse(args.aggConfigs);
- const indexPattern = await indexPatterns.get(args.index);
- const aggConfigs = aggs.createAggConfigs(indexPattern, aggConfigsState);
+ const indexPattern = await indexPatterns.create(args.index.value, true);
+ const aggConfigs = aggs.createAggConfigs(
+ indexPattern,
+ args.aggs!.map((agg) => agg.value)
+ );
return await handleEsaggsRequest(input, args, {
abortSignal: (abortSignal as unknown) as AbortSignal,
diff --git a/src/plugins/data/server/search/search_service.ts b/src/plugins/data/server/search/search_service.ts
index 9d9ffbb41c16f..6c8683220bc4c 100644
--- a/src/plugins/data/server/search/search_service.ts
+++ b/src/plugins/data/server/search/search_service.ts
@@ -256,8 +256,7 @@ export class SearchService implements Plugin {
const searchSourceDependencies: SearchSourceDependencies = {
getConfig: (key: string): T => uiSettingsCache[key],
search: asScoped(request).search,
- // onResponse isn't used on the server, so we just return the original value
- onResponse: (req, res) => res,
+ onResponse: (req, res) => shimHitsTotal(res),
legacy: {
callMsearch: getCallMsearch({
esClient,
diff --git a/src/plugins/data/server/server.api.md b/src/plugins/data/server/server.api.md
index d5ecea527506e..4d24e6d1afd49 100644
--- a/src/plugins/data/server/server.api.md
+++ b/src/plugins/data/server/server.api.md
@@ -25,7 +25,7 @@ import { Ensure } from '@kbn/utility-types';
import { EnvironmentMode } from '@kbn/config';
import { ErrorToastOptions } from 'src/core/public/notifications';
import { ExecutionContext } from 'src/plugins/expressions/common';
-import { ExpressionAstFunction } from 'src/plugins/expressions/common';
+import { ExpressionAstExpression } from 'src/plugins/expressions/common';
import { ExpressionFunctionDefinition } from 'src/plugins/expressions/common';
import { ExpressionsServerSetup } from 'src/plugins/expressions/server';
import { ExpressionValueBoxed } from 'src/plugins/expressions/common';
@@ -77,6 +77,140 @@ export type AggConfigOptions = Assign;
+// Warning: (ae-missing-release-tag) "AggFunctionsMapping" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
+//
+// @public
+export interface AggFunctionsMapping {
+ // Warning: (ae-forgotten-export) The symbol "aggAvg" needs to be exported by the entry point index.d.ts
+ //
+ // (undocumented)
+ aggAvg: ReturnType;
+ // Warning: (ae-forgotten-export) The symbol "aggBucketAvg" needs to be exported by the entry point index.d.ts
+ //
+ // (undocumented)
+ aggBucketAvg: ReturnType;
+ // Warning: (ae-forgotten-export) The symbol "aggBucketMax" needs to be exported by the entry point index.d.ts
+ //
+ // (undocumented)
+ aggBucketMax: ReturnType;
+ // Warning: (ae-forgotten-export) The symbol "aggBucketMin" needs to be exported by the entry point index.d.ts
+ //
+ // (undocumented)
+ aggBucketMin: ReturnType;
+ // Warning: (ae-forgotten-export) The symbol "aggBucketSum" needs to be exported by the entry point index.d.ts
+ //
+ // (undocumented)
+ aggBucketSum: ReturnType;
+ // Warning: (ae-forgotten-export) The symbol "aggCardinality" needs to be exported by the entry point index.d.ts
+ //
+ // (undocumented)
+ aggCardinality: ReturnType;
+ // Warning: (ae-forgotten-export) The symbol "aggCount" needs to be exported by the entry point index.d.ts
+ //
+ // (undocumented)
+ aggCount: ReturnType;
+ // Warning: (ae-forgotten-export) The symbol "aggCumulativeSum" needs to be exported by the entry point index.d.ts
+ //
+ // (undocumented)
+ aggCumulativeSum: ReturnType;
+ // Warning: (ae-forgotten-export) The symbol "aggDateHistogram" needs to be exported by the entry point index.d.ts
+ //
+ // (undocumented)
+ aggDateHistogram: ReturnType;
+ // Warning: (ae-forgotten-export) The symbol "aggDateRange" needs to be exported by the entry point index.d.ts
+ //
+ // (undocumented)
+ aggDateRange: ReturnType;
+ // Warning: (ae-forgotten-export) The symbol "aggDerivative" needs to be exported by the entry point index.d.ts
+ //
+ // (undocumented)
+ aggDerivative: ReturnType;
+ // Warning: (ae-forgotten-export) The symbol "aggFilter" needs to be exported by the entry point index.d.ts
+ //
+ // (undocumented)
+ aggFilter: ReturnType;
+ // Warning: (ae-forgotten-export) The symbol "aggFilters" needs to be exported by the entry point index.d.ts
+ //
+ // (undocumented)
+ aggFilters: ReturnType;
+ // Warning: (ae-forgotten-export) The symbol "aggGeoBounds" needs to be exported by the entry point index.d.ts
+ //
+ // (undocumented)
+ aggGeoBounds: ReturnType;
+ // Warning: (ae-forgotten-export) The symbol "aggGeoCentroid" needs to be exported by the entry point index.d.ts
+ //
+ // (undocumented)
+ aggGeoCentroid: ReturnType;
+ // Warning: (ae-forgotten-export) The symbol "aggGeoHash" needs to be exported by the entry point index.d.ts
+ //
+ // (undocumented)
+ aggGeoHash: ReturnType;
+ // Warning: (ae-forgotten-export) The symbol "aggGeoTile" needs to be exported by the entry point index.d.ts
+ //
+ // (undocumented)
+ aggGeoTile: ReturnType;
+ // Warning: (ae-forgotten-export) The symbol "aggHistogram" needs to be exported by the entry point index.d.ts
+ //
+ // (undocumented)
+ aggHistogram: ReturnType;
+ // Warning: (ae-forgotten-export) The symbol "aggIpRange" needs to be exported by the entry point index.d.ts
+ //
+ // (undocumented)
+ aggIpRange: ReturnType;
+ // Warning: (ae-forgotten-export) The symbol "aggMax" needs to be exported by the entry point index.d.ts
+ //
+ // (undocumented)
+ aggMax: ReturnType;
+ // Warning: (ae-forgotten-export) The symbol "aggMedian" needs to be exported by the entry point index.d.ts
+ //
+ // (undocumented)
+ aggMedian: ReturnType;
+ // Warning: (ae-forgotten-export) The symbol "aggMin" needs to be exported by the entry point index.d.ts
+ //
+ // (undocumented)
+ aggMin: ReturnType;
+ // Warning: (ae-forgotten-export) The symbol "aggMovingAvg" needs to be exported by the entry point index.d.ts
+ //
+ // (undocumented)
+ aggMovingAvg: ReturnType;
+ // Warning: (ae-forgotten-export) The symbol "aggPercentileRanks" needs to be exported by the entry point index.d.ts
+ //
+ // (undocumented)
+ aggPercentileRanks: ReturnType;
+ // Warning: (ae-forgotten-export) The symbol "aggPercentiles" needs to be exported by the entry point index.d.ts
+ //
+ // (undocumented)
+ aggPercentiles: ReturnType;
+ // Warning: (ae-forgotten-export) The symbol "aggRange" needs to be exported by the entry point index.d.ts
+ //
+ // (undocumented)
+ aggRange: ReturnType;
+ // Warning: (ae-forgotten-export) The symbol "aggSerialDiff" needs to be exported by the entry point index.d.ts
+ //
+ // (undocumented)
+ aggSerialDiff: ReturnType;
+ // Warning: (ae-forgotten-export) The symbol "aggSignificantTerms" needs to be exported by the entry point index.d.ts
+ //
+ // (undocumented)
+ aggSignificantTerms: ReturnType;
+ // Warning: (ae-forgotten-export) The symbol "aggStdDeviation" needs to be exported by the entry point index.d.ts
+ //
+ // (undocumented)
+ aggStdDeviation: ReturnType;
+ // Warning: (ae-forgotten-export) The symbol "aggSum" needs to be exported by the entry point index.d.ts
+ //
+ // (undocumented)
+ aggSum: ReturnType;
+ // Warning: (ae-forgotten-export) The symbol "aggTerms" needs to be exported by the entry point index.d.ts
+ //
+ // (undocumented)
+ aggTerms: ReturnType;
+ // Warning: (ae-forgotten-export) The symbol "aggTopHit" needs to be exported by the entry point index.d.ts
+ //
+ // (undocumented)
+ aggTopHit: ReturnType;
+}
+
// Warning: (ae-missing-release-tag) "AggGroupLabels" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
@@ -242,7 +376,7 @@ export const ES_SEARCH_STRATEGY = "es";
// Warning: (ae-missing-release-tag) "EsaggsExpressionFunctionDefinition" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
-export type EsaggsExpressionFunctionDefinition = ExpressionFunctionDefinition<'esaggs', Input, Arguments, Output>;
+export type EsaggsExpressionFunctionDefinition = ExpressionFunctionDefinition<'esaggs', Input_34, Arguments_20, Output_34>;
// Warning: (ae-missing-release-tag) "esFilters" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
@@ -322,7 +456,7 @@ export type ExpressionFunctionKibana = ExpressionFunctionDefinition<'kibana', Ex
// Warning: (ae-missing-release-tag) "ExpressionFunctionKibanaContext" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
-export type ExpressionFunctionKibanaContext = ExpressionFunctionDefinition<'kibana_context', KibanaContext | null, Arguments_2, Promise, ExecutionContext>;
+export type ExpressionFunctionKibanaContext = ExpressionFunctionDefinition<'kibana_context', KibanaContext | null, Arguments_21, Promise, ExecutionContext>;
// Warning: (ae-missing-release-tag) "ExpressionValueSearchContext" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
@@ -705,6 +839,15 @@ export interface IndexPatternAttributes {
typeMeta: string;
}
+// Warning: (ae-forgotten-export) The symbol "name" needs to be exported by the entry point index.d.ts
+// Warning: (ae-forgotten-export) The symbol "Input" needs to be exported by the entry point index.d.ts
+// Warning: (ae-forgotten-export) The symbol "Arguments" needs to be exported by the entry point index.d.ts
+// Warning: (ae-forgotten-export) The symbol "Output" needs to be exported by the entry point index.d.ts
+// Warning: (ae-missing-release-tag) "IndexPatternLoadExpressionFunctionDefinition" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
+//
+// @public (undocumented)
+export type IndexPatternLoadExpressionFunctionDefinition = ExpressionFunctionDefinition;
+
// Warning: (ae-missing-release-tag) "indexPatterns" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
@@ -1268,20 +1411,20 @@ export function usageProvider(core: CoreSetup_2): SearchUsage;
// src/plugins/data/server/index.ts:111:26 - (ae-forgotten-export) The symbol "TruncateFormat" needs to be exported by the entry point index.d.ts
// src/plugins/data/server/index.ts:137:27 - (ae-forgotten-export) The symbol "isFilterable" needs to be exported by the entry point index.d.ts
// src/plugins/data/server/index.ts:137:27 - (ae-forgotten-export) The symbol "isNestedField" needs to be exported by the entry point index.d.ts
-// src/plugins/data/server/index.ts:250:20 - (ae-forgotten-export) The symbol "getRequestInspectorStats" needs to be exported by the entry point index.d.ts
-// src/plugins/data/server/index.ts:250:20 - (ae-forgotten-export) The symbol "getResponseInspectorStats" needs to be exported by the entry point index.d.ts
-// src/plugins/data/server/index.ts:250:20 - (ae-forgotten-export) The symbol "tabifyAggResponse" needs to be exported by the entry point index.d.ts
-// src/plugins/data/server/index.ts:250:20 - (ae-forgotten-export) The symbol "tabifyGetColumns" needs to be exported by the entry point index.d.ts
-// src/plugins/data/server/index.ts:252:1 - (ae-forgotten-export) The symbol "CidrMask" needs to be exported by the entry point index.d.ts
-// src/plugins/data/server/index.ts:253:1 - (ae-forgotten-export) The symbol "dateHistogramInterval" needs to be exported by the entry point index.d.ts
-// src/plugins/data/server/index.ts:262:1 - (ae-forgotten-export) The symbol "InvalidEsCalendarIntervalError" needs to be exported by the entry point index.d.ts
-// src/plugins/data/server/index.ts:263:1 - (ae-forgotten-export) The symbol "InvalidEsIntervalFormatError" needs to be exported by the entry point index.d.ts
-// src/plugins/data/server/index.ts:264:1 - (ae-forgotten-export) The symbol "Ipv4Address" needs to be exported by the entry point index.d.ts
-// src/plugins/data/server/index.ts:268:1 - (ae-forgotten-export) The symbol "isValidEsInterval" needs to be exported by the entry point index.d.ts
-// src/plugins/data/server/index.ts:269:1 - (ae-forgotten-export) The symbol "isValidInterval" needs to be exported by the entry point index.d.ts
-// src/plugins/data/server/index.ts:273:1 - (ae-forgotten-export) The symbol "propFilter" needs to be exported by the entry point index.d.ts
-// src/plugins/data/server/index.ts:276:1 - (ae-forgotten-export) The symbol "toAbsoluteDates" needs to be exported by the entry point index.d.ts
-// src/plugins/data/server/index.ts:277:1 - (ae-forgotten-export) The symbol "calcAutoIntervalLessThan" needs to be exported by the entry point index.d.ts
+// src/plugins/data/server/index.ts:252:20 - (ae-forgotten-export) The symbol "getRequestInspectorStats" needs to be exported by the entry point index.d.ts
+// src/plugins/data/server/index.ts:252:20 - (ae-forgotten-export) The symbol "getResponseInspectorStats" needs to be exported by the entry point index.d.ts
+// src/plugins/data/server/index.ts:252:20 - (ae-forgotten-export) The symbol "tabifyAggResponse" needs to be exported by the entry point index.d.ts
+// src/plugins/data/server/index.ts:252:20 - (ae-forgotten-export) The symbol "tabifyGetColumns" needs to be exported by the entry point index.d.ts
+// src/plugins/data/server/index.ts:254:1 - (ae-forgotten-export) The symbol "CidrMask" needs to be exported by the entry point index.d.ts
+// src/plugins/data/server/index.ts:255:1 - (ae-forgotten-export) The symbol "dateHistogramInterval" needs to be exported by the entry point index.d.ts
+// src/plugins/data/server/index.ts:264:1 - (ae-forgotten-export) The symbol "InvalidEsCalendarIntervalError" needs to be exported by the entry point index.d.ts
+// src/plugins/data/server/index.ts:265:1 - (ae-forgotten-export) The symbol "InvalidEsIntervalFormatError" needs to be exported by the entry point index.d.ts
+// src/plugins/data/server/index.ts:266:1 - (ae-forgotten-export) The symbol "Ipv4Address" needs to be exported by the entry point index.d.ts
+// src/plugins/data/server/index.ts:270:1 - (ae-forgotten-export) The symbol "isValidEsInterval" needs to be exported by the entry point index.d.ts
+// src/plugins/data/server/index.ts:271:1 - (ae-forgotten-export) The symbol "isValidInterval" needs to be exported by the entry point index.d.ts
+// src/plugins/data/server/index.ts:275:1 - (ae-forgotten-export) The symbol "propFilter" needs to be exported by the entry point index.d.ts
+// src/plugins/data/server/index.ts:278:1 - (ae-forgotten-export) The symbol "toAbsoluteDates" needs to be exported by the entry point index.d.ts
+// src/plugins/data/server/index.ts:279:1 - (ae-forgotten-export) The symbol "calcAutoIntervalLessThan" needs to be exported by the entry point index.d.ts
// src/plugins/data/server/index_patterns/index_patterns_service.ts:70:14 - (ae-forgotten-export) The symbol "IndexPatternsService" needs to be exported by the entry point index.d.ts
// src/plugins/data/server/plugin.ts:90:74 - (ae-forgotten-export) The symbol "DataEnhancements" needs to be exported by the entry point index.d.ts
// src/plugins/data/server/search/types.ts:106:5 - (ae-forgotten-export) The symbol "ISearchStartSearchSource" needs to be exported by the entry point index.d.ts
diff --git a/src/plugins/embeddable/public/public.api.md b/src/plugins/embeddable/public/public.api.md
index 1621dfa3f2c3c..56c49997c5eee 100644
--- a/src/plugins/embeddable/public/public.api.md
+++ b/src/plugins/embeddable/public/public.api.md
@@ -32,7 +32,7 @@ import { EuiFlyoutSize } from '@elastic/eui';
import { EuiGlobalToastListToast } from '@elastic/eui';
import { EventEmitter } from 'events';
import { ExclusiveUnion } from '@elastic/eui';
-import { ExpressionAstFunction } from 'src/plugins/expressions/common';
+import { ExpressionAstExpression } from 'src/plugins/expressions/common';
import { History } from 'history';
import { Href } from 'history';
import { HttpSetup as HttpSetup_2 } from 'kibana/public';
diff --git a/src/plugins/expressions/common/execution/execution.ts b/src/plugins/expressions/common/execution/execution.ts
index 9eae7fd717eda..c5c7d82e223b0 100644
--- a/src/plugins/expressions/common/execution/execution.ts
+++ b/src/plugins/expressions/common/execution/execution.ts
@@ -40,6 +40,23 @@ import { getByAlias } from '../util/get_by_alias';
import { ExecutionContract } from './execution_contract';
import { ExpressionExecutionParams } from '../service';
+/**
+ * AbortController is not available in Node until v15, so we
+ * need to temporarily mock it for plugins using expressions
+ * on the server.
+ *
+ * TODO: Remove this once Kibana is upgraded to Node 15.
+ */
+const getNewAbortController = (): AbortController => {
+ try {
+ return new AbortController();
+ } catch (error) {
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
+ const polyfill = require('abortcontroller-polyfill/dist/cjs-ponyfill');
+ return new polyfill.AbortController();
+ }
+};
+
const createAbortErrorValue = () =>
createError({
message: 'The expression was aborted.',
@@ -87,7 +104,7 @@ export class Execution<
/**
* AbortController to cancel this Execution.
*/
- private readonly abortController = new AbortController();
+ private readonly abortController = getNewAbortController();
/**
* Promise that rejects if/when abort controller sends "abort" signal.
diff --git a/src/plugins/vis_type_metric/public/__snapshots__/to_ast.test.ts.snap b/src/plugins/vis_type_metric/public/__snapshots__/to_ast.test.ts.snap
index 117c188c6cce2..a89f41737d7bc 100644
--- a/src/plugins/vis_type_metric/public/__snapshots__/to_ast.test.ts.snap
+++ b/src/plugins/vis_type_metric/public/__snapshots__/to_ast.test.ts.snap
@@ -5,14 +5,22 @@ Object {
"chain": Array [
Object {
"arguments": Object {
- "aggConfigs": Array [
- "[]",
- ],
- "includeFormatHints": Array [
- false,
- ],
+ "aggs": Array [],
"index": Array [
- "123",
+ Object {
+ "chain": Array [
+ Object {
+ "arguments": Object {
+ "id": Array [
+ "123",
+ ],
+ },
+ "function": "indexPatternLoad",
+ "type": "function",
+ },
+ ],
+ "type": "expression",
+ },
],
"metricsAtAllLevels": Array [
false,
@@ -43,14 +51,22 @@ Object {
"chain": Array [
Object {
"arguments": Object {
- "aggConfigs": Array [
- "[]",
- ],
- "includeFormatHints": Array [
- false,
- ],
+ "aggs": Array [],
"index": Array [
- "123",
+ Object {
+ "chain": Array [
+ Object {
+ "arguments": Object {
+ "id": Array [
+ "123",
+ ],
+ },
+ "function": "indexPatternLoad",
+ "type": "function",
+ },
+ ],
+ "type": "expression",
+ },
],
"metricsAtAllLevels": Array [
false,
diff --git a/src/plugins/vis_type_metric/public/to_ast.ts b/src/plugins/vis_type_metric/public/to_ast.ts
index 23e4664b82414..b02496bdfd117 100644
--- a/src/plugins/vis_type_metric/public/to_ast.ts
+++ b/src/plugins/vis_type_metric/public/to_ast.ts
@@ -21,7 +21,10 @@ import { get } from 'lodash';
import { getVisSchemas, SchemaConfig, Vis } from '../../visualizations/public';
import { buildExpression, buildExpressionFunction } from '../../expressions/public';
import { MetricVisExpressionFunctionDefinition } from './metric_vis_fn';
-import { EsaggsExpressionFunctionDefinition } from '../../data/common/search/expressions';
+import {
+ EsaggsExpressionFunctionDefinition,
+ IndexPatternLoadExpressionFunctionDefinition,
+} from '../../data/public';
const prepareDimension = (params: SchemaConfig) => {
const visdimension = buildExpressionFunction('visdimension', { accessor: params.accessor });
@@ -35,13 +38,15 @@ const prepareDimension = (params: SchemaConfig) => {
};
export const toExpressionAst = (vis: Vis, params: any) => {
- // soon this becomes: const esaggs = vis.data.aggs!.toExpressionAst();
const esaggs = buildExpressionFunction('esaggs', {
- index: vis.data.indexPattern!.id!,
+ index: buildExpression([
+ buildExpressionFunction('indexPatternLoad', {
+ id: vis.data.indexPattern!.id!,
+ }),
+ ]),
metricsAtAllLevels: vis.isHierarchical(),
partialRows: vis.params.showPartialRows || false,
- aggConfigs: JSON.stringify(vis.data.aggs!.aggs),
- includeFormatHints: false,
+ aggs: vis.data.aggs!.aggs.map((agg) => buildExpression(agg.toExpressionAst())),
});
const schemas = getVisSchemas(vis, params);
diff --git a/src/plugins/vis_type_table/public/__snapshots__/to_ast.test.ts.snap b/src/plugins/vis_type_table/public/__snapshots__/to_ast.test.ts.snap
index d2298e6fb3eb5..bb63a6f4e5e6a 100644
--- a/src/plugins/vis_type_table/public/__snapshots__/to_ast.test.ts.snap
+++ b/src/plugins/vis_type_table/public/__snapshots__/to_ast.test.ts.snap
@@ -5,14 +5,22 @@ Object {
"chain": Array [
Object {
"arguments": Object {
- "aggConfigs": Array [
- "[]",
- ],
- "includeFormatHints": Array [
- false,
- ],
+ "aggs": Array [],
"index": Array [
- "123",
+ Object {
+ "chain": Array [
+ Object {
+ "arguments": Object {
+ "id": Array [
+ "123",
+ ],
+ },
+ "function": "indexPatternLoad",
+ "type": "function",
+ },
+ ],
+ "type": "expression",
+ },
],
"metricsAtAllLevels": Array [
false,
@@ -43,14 +51,22 @@ Object {
"chain": Array [
Object {
"arguments": Object {
- "aggConfigs": Array [
- "[]",
- ],
- "includeFormatHints": Array [
- false,
- ],
+ "aggs": Array [],
"index": Array [
- "123",
+ Object {
+ "chain": Array [
+ Object {
+ "arguments": Object {
+ "id": Array [
+ "123",
+ ],
+ },
+ "function": "indexPatternLoad",
+ "type": "function",
+ },
+ ],
+ "type": "expression",
+ },
],
"metricsAtAllLevels": Array [
false,
diff --git a/src/plugins/vis_type_table/public/to_ast.ts b/src/plugins/vis_type_table/public/to_ast.ts
index 449e2dde7f7c9..78d6efd31a115 100644
--- a/src/plugins/vis_type_table/public/to_ast.ts
+++ b/src/plugins/vis_type_table/public/to_ast.ts
@@ -17,7 +17,10 @@
* under the License.
*/
-import { EsaggsExpressionFunctionDefinition } from '../../data/common/search/expressions';
+import {
+ EsaggsExpressionFunctionDefinition,
+ IndexPatternLoadExpressionFunctionDefinition,
+} from '../../data/public';
import { buildExpression, buildExpressionFunction } from '../../expressions/public';
import { getVisSchemas, Vis, BuildPipelineParams } from '../../visualizations/public';
import { TableExpressionFunctionDefinition } from './table_vis_fn';
@@ -49,11 +52,14 @@ const buildTableVisConfig = (
export const toExpressionAst = (vis: Vis, params: BuildPipelineParams) => {
const esaggs = buildExpressionFunction('esaggs', {
- index: vis.data.indexPattern!.id!,
+ index: buildExpression([
+ buildExpressionFunction('indexPatternLoad', {
+ id: vis.data.indexPattern!.id!,
+ }),
+ ]),
metricsAtAllLevels: vis.isHierarchical(),
partialRows: vis.params.showPartialRows,
- aggConfigs: JSON.stringify(vis.data.aggs!.aggs),
- includeFormatHints: false,
+ aggs: vis.data.aggs!.aggs.map((agg) => buildExpression(agg.toExpressionAst())),
});
const schemas = getVisSchemas(vis, params);
diff --git a/src/plugins/vis_type_tagcloud/public/__snapshots__/to_ast.test.ts.snap b/src/plugins/vis_type_tagcloud/public/__snapshots__/to_ast.test.ts.snap
index d64bdfb1f46f9..a8bc0b4c51678 100644
--- a/src/plugins/vis_type_tagcloud/public/__snapshots__/to_ast.test.ts.snap
+++ b/src/plugins/vis_type_tagcloud/public/__snapshots__/to_ast.test.ts.snap
@@ -5,14 +5,22 @@ Object {
"chain": Array [
Object {
"arguments": Object {
- "aggConfigs": Array [
- "[]",
- ],
- "includeFormatHints": Array [
- false,
- ],
+ "aggs": Array [],
"index": Array [
- "123",
+ Object {
+ "chain": Array [
+ Object {
+ "arguments": Object {
+ "id": Array [
+ "123",
+ ],
+ },
+ "function": "indexPatternLoad",
+ "type": "function",
+ },
+ ],
+ "type": "expression",
+ },
],
"metricsAtAllLevels": Array [
false,
@@ -96,14 +104,22 @@ Object {
"chain": Array [
Object {
"arguments": Object {
- "aggConfigs": Array [
- "[]",
- ],
- "includeFormatHints": Array [
- false,
- ],
+ "aggs": Array [],
"index": Array [
- "123",
+ Object {
+ "chain": Array [
+ Object {
+ "arguments": Object {
+ "id": Array [
+ "123",
+ ],
+ },
+ "function": "indexPatternLoad",
+ "type": "function",
+ },
+ ],
+ "type": "expression",
+ },
],
"metricsAtAllLevels": Array [
false,
diff --git a/src/plugins/vis_type_tagcloud/public/to_ast.ts b/src/plugins/vis_type_tagcloud/public/to_ast.ts
index 69b55b5898257..702e976fb2547 100644
--- a/src/plugins/vis_type_tagcloud/public/to_ast.ts
+++ b/src/plugins/vis_type_tagcloud/public/to_ast.ts
@@ -17,7 +17,10 @@
* under the License.
*/
-import { EsaggsExpressionFunctionDefinition } from '../../data/common/search/expressions';
+import {
+ EsaggsExpressionFunctionDefinition,
+ IndexPatternLoadExpressionFunctionDefinition,
+} from '../../data/public';
import { buildExpression, buildExpressionFunction } from '../../expressions/public';
import { getVisSchemas, SchemaConfig, Vis, BuildPipelineParams } from '../../visualizations/public';
import { TagcloudExpressionFunctionDefinition } from './tag_cloud_fn';
@@ -36,11 +39,14 @@ const prepareDimension = (params: SchemaConfig) => {
export const toExpressionAst = (vis: Vis, params: BuildPipelineParams) => {
const esaggs = buildExpressionFunction('esaggs', {
- index: vis.data.indexPattern!.id!,
+ index: buildExpression([
+ buildExpressionFunction('indexPatternLoad', {
+ id: vis.data.indexPattern!.id!,
+ }),
+ ]),
metricsAtAllLevels: vis.isHierarchical(),
partialRows: false,
- aggConfigs: JSON.stringify(vis.data.aggs!.aggs),
- includeFormatHints: false,
+ aggs: vis.data.aggs!.aggs.map((agg) => buildExpression(agg.toExpressionAst())),
});
const schemas = getVisSchemas(vis, params);
diff --git a/src/plugins/vis_type_vislib/public/to_ast.ts b/src/plugins/vis_type_vislib/public/to_ast.ts
index 7cd55ccd32ebc..3a05410ff006b 100644
--- a/src/plugins/vis_type_vislib/public/to_ast.ts
+++ b/src/plugins/vis_type_vislib/public/to_ast.ts
@@ -88,12 +88,11 @@ export const toExpressionAst: VisToExpressionAst = async (vis
visConfig.dimensions = dimensions;
- const configStr = JSON.stringify(visConfig).replace(/\\/g, `\\\\`).replace(/'/g, `\\'`);
const visTypeXy = buildExpressionFunction(
vislibVisName,
{
type: vis.type.name,
- visConfig: configStr,
+ visConfig: JSON.stringify(visConfig),
}
);
diff --git a/src/plugins/vis_type_vislib/public/to_ast_esaggs.ts b/src/plugins/vis_type_vislib/public/to_ast_esaggs.ts
index a7312c9d36cbb..2835e5cc1c255 100644
--- a/src/plugins/vis_type_vislib/public/to_ast_esaggs.ts
+++ b/src/plugins/vis_type_vislib/public/to_ast_esaggs.ts
@@ -18,23 +18,28 @@
*/
import { Vis } from '../../visualizations/public';
-import { buildExpressionFunction } from '../../expressions/public';
-import { EsaggsExpressionFunctionDefinition } from '../../data/public';
+import { buildExpression, buildExpressionFunction } from '../../expressions/public';
+import {
+ EsaggsExpressionFunctionDefinition,
+ IndexPatternLoadExpressionFunctionDefinition,
+} from '../../data/public';
import { PieVisParams } from './pie';
import { BasicVislibParams } from './types';
/**
* Get esaggs expressions function
- * TODO: replace this with vis.data.aggs!.toExpressionAst();
* @param vis
*/
export function getEsaggsFn(vis: Vis | Vis) {
return buildExpressionFunction('esaggs', {
- index: vis.data.indexPattern!.id!,
+ index: buildExpression([
+ buildExpressionFunction('indexPatternLoad', {
+ id: vis.data.indexPattern!.id!,
+ }),
+ ]),
metricsAtAllLevels: vis.isHierarchical(),
partialRows: false,
- aggConfigs: JSON.stringify(vis.data.aggs!.aggs),
- includeFormatHints: false,
+ aggs: vis.data.aggs!.aggs.map((agg) => buildExpression(agg.toExpressionAst())),
});
}
diff --git a/src/plugins/visualizations/public/legacy/build_pipeline.ts b/src/plugins/visualizations/public/legacy/build_pipeline.ts
index 29f6ec9b069a7..c10f47c39b47d 100644
--- a/src/plugins/visualizations/public/legacy/build_pipeline.ts
+++ b/src/plugins/visualizations/public/legacy/build_pipeline.ts
@@ -17,7 +17,11 @@
* under the License.
*/
-import { formatExpression, SerializedFieldFormat } from '../../../../plugins/expressions/public';
+import {
+ buildExpression,
+ formatExpression,
+ SerializedFieldFormat,
+} from '../../../../plugins/expressions/public';
import { IAggConfig, search, TimefilterContract } from '../../../../plugins/data/public';
import { Vis, VisParams } from '../types';
const { isDateHistogramBucketAggConfig } = search.aggs;
@@ -281,10 +285,18 @@ export const buildPipeline = async (vis: Vis, params: BuildPipelineParams) => {
// request handler
if (vis.type.requestHandler === 'courier') {
pipeline += `esaggs
- ${prepareString('index', indexPattern!.id)}
+ index={indexPatternLoad ${prepareString('id', indexPattern!.id)}}
metricsAtAllLevels=${vis.isHierarchical()}
- partialRows=${vis.params.showPartialRows || false}
- ${prepareJson('aggConfigs', vis.data.aggs!.aggs)} | `;
+ partialRows=${vis.params.showPartialRows || false} `;
+ if (vis.data.aggs) {
+ vis.data.aggs.aggs.forEach((agg) => {
+ const ast = agg.toExpressionAst();
+ if (ast) {
+ pipeline += `aggs={${buildExpression(ast).toString()}} `;
+ }
+ });
+ }
+ pipeline += `| `;
}
const schemas = getSchemas(vis, params);
diff --git a/test/interpreter_functional/plugins/kbn_tp_run_pipeline/kibana.json b/test/interpreter_functional/plugins/kbn_tp_run_pipeline/kibana.json
index 7eafb185617c4..084cee2fddf08 100644
--- a/test/interpreter_functional/plugins/kbn_tp_run_pipeline/kibana.json
+++ b/test/interpreter_functional/plugins/kbn_tp_run_pipeline/kibana.json
@@ -8,7 +8,7 @@
"kibanaUtils",
"expressions"
],
- "server": false,
+ "server": true,
"ui": true,
"requiredBundles": [
"inspector"
diff --git a/test/interpreter_functional/plugins/kbn_tp_run_pipeline/server/index.ts b/test/interpreter_functional/plugins/kbn_tp_run_pipeline/server/index.ts
new file mode 100644
index 0000000000000..2e55966785909
--- /dev/null
+++ b/test/interpreter_functional/plugins/kbn_tp_run_pipeline/server/index.ts
@@ -0,0 +1,23 @@
+/*
+ * Licensed to Elasticsearch B.V. under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Elasticsearch B.V. licenses this file to you under
+ * the Apache License, Version 2.0 (the "License"); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import { PluginInitializer } from '../../../../../src/core/server';
+import { TestPlugin, TestPluginSetup, TestPluginStart } from './plugin';
+
+export const plugin: PluginInitializer = () => new TestPlugin();
diff --git a/test/interpreter_functional/plugins/kbn_tp_run_pipeline/server/plugin.ts b/test/interpreter_functional/plugins/kbn_tp_run_pipeline/server/plugin.ts
new file mode 100644
index 0000000000000..dfac64ab8a444
--- /dev/null
+++ b/test/interpreter_functional/plugins/kbn_tp_run_pipeline/server/plugin.ts
@@ -0,0 +1,63 @@
+/*
+ * Licensed to Elasticsearch B.V. under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Elasticsearch B.V. licenses this file to you under
+ * the Apache License, Version 2.0 (the "License"); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import { schema } from '@kbn/config-schema';
+import { CoreSetup, Plugin, HttpResponsePayload } from '../../../../../src/core/server';
+import { PluginStart as DataPluginStart } from '../../../../../src/plugins/data/server';
+import { ExpressionsServerStart } from '../../../../../src/plugins/expressions/server';
+
+export interface TestStartDeps {
+ data: DataPluginStart;
+ expressions: ExpressionsServerStart;
+}
+
+export class TestPlugin implements Plugin {
+ public setup(core: CoreSetup) {
+ const router = core.http.createRouter();
+
+ router.post(
+ {
+ path: '/api/interpreter_functional/run_expression',
+ validate: {
+ body: schema.object({
+ input: schema.maybe(schema.nullable(schema.object({}, { unknowns: 'allow' }))),
+ expression: schema.string(),
+ }),
+ },
+ },
+ async (context, req, res) => {
+ const [, { expressions }] = await core.getStartServices();
+ const output = await expressions.run(
+ req.body.expression,
+ req.body.input,
+ {
+ kibanaRequest: req,
+ }
+ );
+ return res.ok({ body: output });
+ }
+ );
+ }
+
+ public start() {}
+ public stop() {}
+}
+
+export type TestPluginSetup = ReturnType;
+export type TestPluginStart = ReturnType;
diff --git a/test/interpreter_functional/plugins/kbn_tp_run_pipeline/tsconfig.json b/test/interpreter_functional/plugins/kbn_tp_run_pipeline/tsconfig.json
index f77a5eaffc301..3d9d8ca9451d4 100644
--- a/test/interpreter_functional/plugins/kbn_tp_run_pipeline/tsconfig.json
+++ b/test/interpreter_functional/plugins/kbn_tp_run_pipeline/tsconfig.json
@@ -8,6 +8,7 @@
"index.ts",
"public/**/*.ts",
"public/**/*.tsx",
+ "server/**/*.ts",
"../../../../typings/**/*",
],
"exclude": [],
diff --git a/test/interpreter_functional/test_suites/run_pipeline/basic.ts b/test/interpreter_functional/test_suites/run_pipeline/basic.ts
index fa83174fe308a..fc7c0428631c6 100644
--- a/test/interpreter_functional/test_suites/run_pipeline/basic.ts
+++ b/test/interpreter_functional/test_suites/run_pipeline/basic.ts
@@ -54,12 +54,10 @@ export default function ({
// rather we want to use this to do integration tests.
describe('full expression', () => {
- const expression = `kibana | kibana_context | esaggs index='logstash-*' aggConfigs='[
- {"id":"1","enabled":true,"type":"count","schema":"metric","params":{}},
- {"id":"2","enabled":true,"type":"terms","schema":"segment","params":
- {"field":"response.raw","size":4,"order":"desc","orderBy":"1"}
- }]' |
- metricVis metric={visdimension 1 format="number"} bucket={visdimension 0}
+ const expression = `kibana | kibana_context | esaggs index={indexPatternLoad id='logstash-*'}
+ aggs={aggCount id="1" enabled=true schema="metric"}
+ aggs={aggTerms id="2" enabled=true schema="segment" field="response.raw" size=4 order="desc" orderBy="1"}
+ | metricVis metric={visdimension 1 format="number"} bucket={visdimension 0}
`;
// we can execute an expression and validate the result manually:
@@ -94,11 +92,10 @@ export default function ({
// possible to retrieve the intermediate result and reuse it in later expressions
describe('reusing partial results', () => {
it('does some screenshot comparisons', async () => {
- const expression = `kibana | kibana_context | esaggs index='logstash-*' aggConfigs='[
- {"id":"1","enabled":true,"type":"count","schema":"metric","params":{}},
- {"id":"2","enabled":true,"type":"terms","schema":"segment","params":
- {"field":"response.raw","size":4,"order":"desc","orderBy":"1"}
- }]'`;
+ const expression = `kibana | kibana_context | esaggs index={indexPatternLoad id='logstash-*'}
+ aggs={aggCount id="1" enabled=true schema="metric"}
+ aggs={aggTerms id="2" enabled=true schema="segment" field="response.raw" size=4 order="desc" orderBy="1"}
+ `;
// we execute the part of expression that fetches the data and store its response
const context = await expectExpression('partial_test', expression).getResponse();
diff --git a/test/interpreter_functional/test_suites/run_pipeline/esaggs.ts b/test/interpreter_functional/test_suites/run_pipeline/esaggs.ts
index 96140b003af18..d7908c7bb94d1 100644
--- a/test/interpreter_functional/test_suites/run_pipeline/esaggs.ts
+++ b/test/interpreter_functional/test_suites/run_pipeline/esaggs.ts
@@ -33,54 +33,67 @@ export default function ({
getService,
updateBaselines,
}: FtrProviderContext & { updateBaselines: boolean }) {
+ const supertest = getService('supertest');
let expectExpression: ExpectExpression;
+
+ const expectClientToMatchServer = async (title: string, expression: string) => {
+ const clientResult = await expectExpression(title, expression).getResponse();
+ await supertest
+ .post('/api/interpreter_functional/run_expression')
+ .set('kbn-xsrf', 'anything')
+ .send({ expression, input: undefined })
+ .expect(200)
+ .expect(({ body }) => {
+ expect(body.rows).to.eql(clientResult.rows);
+ });
+ };
+
describe('esaggs pipeline expression tests', () => {
before(() => {
expectExpression = expectExpressionProvider({ getService, updateBaselines });
});
- describe('correctly renders tagcloud', () => {
+ describe('correctly filters based on context', () => {
it('filters on index pattern primary date field by default', async () => {
- const aggConfigs = [{ id: 1, enabled: true, type: 'count', schema: 'metric', params: {} }];
const timeRange = {
from: '2006-09-21T00:00:00Z',
to: '2015-09-22T00:00:00Z',
};
const expression = `
kibana_context timeRange='${JSON.stringify(timeRange)}'
- | esaggs index='logstash-*' aggConfigs='${JSON.stringify(aggConfigs)}'
+ | esaggs index={indexPatternLoad id='logstash-*'}
+ aggs={aggCount id="1" enabled=true schema="metric"}
`;
const result = await expectExpression('esaggs_primary_timefield', expression).getResponse();
expect(getCell(result, 0, 0)).to.be(9375);
});
it('filters on the specified date field', async () => {
- const aggConfigs = [{ id: 1, enabled: true, type: 'count', schema: 'metric', params: {} }];
const timeRange = {
from: '2006-09-21T00:00:00Z',
to: '2015-09-22T00:00:00Z',
};
const expression = `
kibana_context timeRange='${JSON.stringify(timeRange)}'
- | esaggs index='logstash-*' timeFields='relatedContent.article:published_time' aggConfigs='${JSON.stringify(
- aggConfigs
- )}'
+ | esaggs index={indexPatternLoad id='logstash-*'}
+ timeFields='relatedContent.article:published_time'
+ aggs={aggCount id="1" enabled=true schema="metric"}
`;
const result = await expectExpression('esaggs_other_timefield', expression).getResponse();
expect(getCell(result, 0, 0)).to.be(11134);
});
it('filters on multiple specified date field', async () => {
- const aggConfigs = [{ id: 1, enabled: true, type: 'count', schema: 'metric', params: {} }];
const timeRange = {
from: '2006-09-21T00:00:00Z',
to: '2015-09-22T00:00:00Z',
};
const expression = `
kibana_context timeRange='${JSON.stringify(timeRange)}'
- | esaggs index='logstash-*' timeFields='relatedContent.article:published_time' timeFields='@timestamp' aggConfigs='${JSON.stringify(
- aggConfigs
- )}'
+ | esaggs index={indexPatternLoad id='logstash-*'}
+ timeFields='relatedContent.article:published_time'
+ timeFields='@timestamp'
+ aggs={aggCount id="1" enabled=true schema="metric"}
`;
const result = await expectExpression(
'esaggs_multiple_timefields',
@@ -89,5 +102,69 @@ export default function ({
expect(getCell(result, 0, 0)).to.be(7452);
});
});
+
+ describe('correctly runs on the server', () => {
+ it('runs the provided agg on the server', async () => {
+ const expression = `
+ esaggs index={indexPatternLoad id='logstash-*'}
+ aggs={aggAvg id="1" enabled=true schema="metric" field="bytes"}
+ `;
+ await supertest
+ .post('/api/interpreter_functional/run_expression')
+ .set('kbn-xsrf', 'anything')
+ .send({ expression, input: undefined })
+ .expect(200)
+ .expect(({ body }) => {
+ expect(body.columns[0].meta.index).to.be('logstash-*');
+ expect(body.columns[0].meta.source).to.be('esaggs');
+ expect(body.columns[0].meta.sourceParams.type).to.be('avg');
+ expect(getCell(body, 0, 0)).to.be(5727.3136246786635);
+ });
+ });
+
+ it('works with timeRange filters', async () => {
+ const timeRange = {
+ from: '2006-09-21T00:00:00Z',
+ to: '2015-09-22T00:00:00Z',
+ };
+ // we need to manually pass timeRange in the input until
+ // kibana_context is supported on the server
+ const kibanaContext = {
+ type: 'kibana_context',
+ timeRange,
+ };
+ const expression = `
+ esaggs index={indexPatternLoad id='logstash-*'}
+ aggs={aggCount id="1" enabled=true schema="metric"}
+ `;
+ await supertest
+ .post('/api/interpreter_functional/run_expression')
+ .set('kbn-xsrf', 'anything')
+ .send({ expression, input: kibanaContext })
+ .expect(200)
+ .expect(({ body }) => {
+ expect(getCell(body, 0, 0)).to.be(9375);
+ });
+ });
+
+ it('returns same results on client & server', async () => {
+ const a = `
+ esaggs index={indexPatternLoad id='logstash-*'}
+ aggs={aggCount id="1" enabled=true schema="metric"}
+ aggs={aggTerms id="2" enabled=true schema="segment" field="response.raw"}
+ `;
+ await expectClientToMatchServer('multiple_aggs', a);
+
+ // const b = `
+ // esaggs index={indexPatternLoad id='logstash-*'}
+ // aggs={aggCount id="1" enabled=true schema="metric"}
+ // `;
+
+ // const c = `
+ // esaggs index={indexPatternLoad id='logstash-*'}
+ // aggs={aggCount id="1" enabled=true schema="metric"}
+ // `;
+ });
+ });
});
}
diff --git a/test/interpreter_functional/test_suites/run_pipeline/metric.ts b/test/interpreter_functional/test_suites/run_pipeline/metric.ts
index a816cdeb4c6e5..ed69b42844d4d 100644
--- a/test/interpreter_functional/test_suites/run_pipeline/metric.ts
+++ b/test/interpreter_functional/test_suites/run_pipeline/metric.ts
@@ -33,14 +33,10 @@ export default function ({
describe('correctly renders metric', () => {
let dataContext: ExpressionResult;
before(async () => {
- const expression = `kibana | kibana_context | esaggs index='logstash-*' aggConfigs='[
- {"id":"1","enabled":true,"type":"count","schema":"metric","params":{}},
- {"id":"1","enabled":true,"type":"max","schema":"metric","params":
- {"field":"bytes"}
- },
- {"id":"2","enabled":true,"type":"terms","schema":"segment","params":
- {"field":"response.raw","size":4,"order":"desc","orderBy":"1"}
- }]'`;
+ const expression = `kibana | kibana_context | esaggs index={indexPatternLoad id='logstash-*'}
+ aggs={aggCount id="1" enabled=true schema="metric"}
+ aggs={aggMax id="1" enabled=true schema="metric" field="bytes"}
+ aggs={aggTerms id="2" enabled=true schema="segment" field="response.raw" size=4 order="desc" orderBy="1"}`;
// we execute the part of expression that fetches the data and store its response
dataContext = await expectExpression('partial_metric_test', expression).getResponse();
});
diff --git a/test/interpreter_functional/test_suites/run_pipeline/tag_cloud.ts b/test/interpreter_functional/test_suites/run_pipeline/tag_cloud.ts
index b8da8f2f0c146..a78a1817accdb 100644
--- a/test/interpreter_functional/test_suites/run_pipeline/tag_cloud.ts
+++ b/test/interpreter_functional/test_suites/run_pipeline/tag_cloud.ts
@@ -33,11 +33,9 @@ export default function ({
describe('correctly renders tagcloud', () => {
let dataContext: ExpressionResult;
before(async () => {
- const expression = `kibana | kibana_context | esaggs index='logstash-*' aggConfigs='[
- {"id":"1","enabled":true,"type":"count","schema":"metric","params":{}},
- {"id":"2","enabled":true,"type":"terms","schema":"segment","params":
- {"field":"response.raw","size":4,"order":"desc","orderBy":"1"}
- }]'`;
+ const expression = `kibana | kibana_context | esaggs index={indexPatternLoad id='logstash-*'}
+ aggs={aggCount id="1" enabled=true schema="metric"}
+ aggs={aggTerms id="2" enabled=true schema="segment" field="response.raw" size=4 order="desc" orderBy="1"}`;
// we execute the part of expression that fetches the data and store its response
dataContext = await expectExpression('partial_tagcloud_test', expression).getResponse();
});
diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/indexpattern.test.ts b/x-pack/plugins/lens/public/indexpattern_datasource/indexpattern.test.ts
index f70ab7ce5f87d..042ea0353ac63 100644
--- a/x-pack/plugins/lens/public/indexpattern_datasource/indexpattern.test.ts
+++ b/x-pack/plugins/lens/public/indexpattern_datasource/indexpattern.test.ts
@@ -324,14 +324,81 @@ describe('IndexPattern Data Source', () => {
"chain": Array [
Object {
"arguments": Object {
- "aggConfigs": Array [
- "[{\\"id\\":\\"col1\\",\\"enabled\\":true,\\"type\\":\\"count\\",\\"schema\\":\\"metric\\",\\"params\\":{}},{\\"id\\":\\"col2\\",\\"enabled\\":true,\\"type\\":\\"date_histogram\\",\\"schema\\":\\"segment\\",\\"params\\":{\\"field\\":\\"timestamp\\",\\"useNormalizedEsInterval\\":true,\\"interval\\":\\"1d\\",\\"drop_partials\\":false,\\"min_doc_count\\":0,\\"extended_bounds\\":{}}}]",
- ],
- "includeFormatHints": Array [
- true,
+ "aggs": Array [
+ Object {
+ "chain": Array [
+ Object {
+ "arguments": Object {
+ "enabled": Array [
+ true,
+ ],
+ "id": Array [
+ "col1",
+ ],
+ "schema": Array [
+ "metric",
+ ],
+ },
+ "function": "aggCount",
+ "type": "function",
+ },
+ ],
+ "type": "expression",
+ },
+ Object {
+ "chain": Array [
+ Object {
+ "arguments": Object {
+ "drop_partials": Array [
+ false,
+ ],
+ "enabled": Array [
+ true,
+ ],
+ "extended_bounds": Array [
+ "{}",
+ ],
+ "field": Array [
+ "timestamp",
+ ],
+ "id": Array [
+ "col2",
+ ],
+ "interval": Array [
+ "1d",
+ ],
+ "min_doc_count": Array [
+ 0,
+ ],
+ "schema": Array [
+ "segment",
+ ],
+ "useNormalizedEsInterval": Array [
+ true,
+ ],
+ },
+ "function": "aggDateHistogram",
+ "type": "function",
+ },
+ ],
+ "type": "expression",
+ },
],
"index": Array [
- "1",
+ Object {
+ "chain": Array [
+ Object {
+ "arguments": Object {
+ "id": Array [
+ "1",
+ ],
+ },
+ "function": "indexPatternLoad",
+ "type": "function",
+ },
+ ],
+ "type": "expression",
+ },
],
"metricsAtAllLevels": Array [
false,
diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/cardinality.tsx b/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/cardinality.tsx
index 2dc3946c62a09..95e905f6021be 100644
--- a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/cardinality.tsx
+++ b/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/cardinality.tsx
@@ -5,6 +5,8 @@
*/
import { i18n } from '@kbn/i18n';
+import { AggFunctionsMapping } from '../../../../../../../src/plugins/data/public';
+import { buildExpressionFunction } from '../../../../../../../src/plugins/expressions/public';
import { OperationDefinition } from './index';
import { FormattedIndexPatternColumn, FieldBasedIndexPatternColumn } from './column_types';
@@ -75,16 +77,14 @@ export const cardinalityOperation: OperationDefinition ({
- id: columnId,
- enabled: true,
- type: OPERATION_TYPE,
- schema: 'metric',
- params: {
+ toEsAggsFn: (column, columnId) => {
+ return buildExpressionFunction('aggCardinality', {
+ id: columnId,
+ enabled: true,
+ schema: 'metric',
field: column.sourceField,
- missing: 0,
- },
- }),
+ }).toAst();
+ },
onFieldChange: (oldColumn, field) => {
return {
...oldColumn,
diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/count.tsx b/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/count.tsx
index 02a69ad8e550f..0d8ed44f528a8 100644
--- a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/count.tsx
+++ b/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/count.tsx
@@ -5,6 +5,8 @@
*/
import { i18n } from '@kbn/i18n';
+import { AggFunctionsMapping } from '../../../../../../../src/plugins/data/public';
+import { buildExpressionFunction } from '../../../../../../../src/plugins/expressions/public';
import { OperationDefinition } from './index';
import { FormattedIndexPatternColumn, FieldBasedIndexPatternColumn } from './column_types';
import { IndexPatternField } from '../../types';
@@ -68,13 +70,13 @@ export const countOperation: OperationDefinition ({
- id: columnId,
- enabled: true,
- type: 'count',
- schema: 'metric',
- params: {},
- }),
+ toEsAggsFn: (column, columnId) => {
+ return buildExpressionFunction('aggCount', {
+ id: columnId,
+ enabled: true,
+ schema: 'metric',
+ }).toAst();
+ },
isTransferable: () => {
return true;
},
diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/date_histogram.test.tsx b/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/date_histogram.test.tsx
index 558fab02ad084..e40b9ccf89c1a 100644
--- a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/date_histogram.test.tsx
+++ b/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/date_histogram.test.tsx
@@ -243,26 +243,26 @@ describe('date_histogram', () => {
});
});
- describe('toEsAggsConfig', () => {
+ describe('toEsAggsFn', () => {
it('should reflect params correctly', () => {
- const esAggsConfig = dateHistogramOperation.toEsAggsConfig(
+ const esAggsFn = dateHistogramOperation.toEsAggsFn(
state.layers.first.columns.col1 as DateHistogramIndexPatternColumn,
'col1',
state.indexPatterns['1']
);
- expect(esAggsConfig).toEqual(
+ expect(esAggsFn).toEqual(
expect.objectContaining({
- params: expect.objectContaining({
- interval: '42w',
- field: 'timestamp',
- useNormalizedEsInterval: true,
+ arguments: expect.objectContaining({
+ interval: ['42w'],
+ field: ['timestamp'],
+ useNormalizedEsInterval: [true],
}),
})
);
});
it('should not use normalized es interval for rollups', () => {
- const esAggsConfig = dateHistogramOperation.toEsAggsConfig(
+ const esAggsFn = dateHistogramOperation.toEsAggsFn(
state.layers.first.columns.col1 as DateHistogramIndexPatternColumn,
'col1',
{
@@ -301,12 +301,12 @@ describe('date_histogram', () => {
]),
}
);
- expect(esAggsConfig).toEqual(
+ expect(esAggsFn).toEqual(
expect.objectContaining({
- params: expect.objectContaining({
- interval: '42w',
- field: 'timestamp',
- useNormalizedEsInterval: false,
+ arguments: expect.objectContaining({
+ interval: ['42w'],
+ field: ['timestamp'],
+ useNormalizedEsInterval: [false],
}),
})
);
diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/date_histogram.tsx b/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/date_histogram.tsx
index ca426fb53a3ab..c48b9dad6c0d5 100644
--- a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/date_histogram.tsx
+++ b/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/date_histogram.tsx
@@ -22,7 +22,12 @@ import {
import { updateColumnParam } from '../layer_helpers';
import { OperationDefinition } from './index';
import { FieldBasedIndexPatternColumn } from './column_types';
-import { IndexPatternAggRestrictions, search } from '../../../../../../../src/plugins/data/public';
+import {
+ AggFunctionsMapping,
+ IndexPatternAggRestrictions,
+ search,
+} from '../../../../../../../src/plugins/data/public';
+import { buildExpressionFunction } from '../../../../../../../src/plugins/expressions/public';
import { getInvalidFieldMessage } from './helpers';
const { isValidInterval } = search.aggs;
@@ -123,23 +128,20 @@ export const dateHistogramOperation: OperationDefinition<
sourceField: field.name,
};
},
- toEsAggsConfig: (column, columnId, indexPattern) => {
+ toEsAggsFn: (column, columnId, indexPattern) => {
const usedField = indexPattern.getFieldByName(column.sourceField);
- return {
+ return buildExpressionFunction('aggDateHistogram', {
id: columnId,
enabled: true,
- type: 'date_histogram',
schema: 'segment',
- params: {
- field: column.sourceField,
- time_zone: column.params.timeZone,
- useNormalizedEsInterval: !usedField?.aggregationRestrictions?.date_histogram,
- interval: column.params.interval,
- drop_partials: false,
- min_doc_count: 0,
- extended_bounds: {},
- },
- };
+ field: column.sourceField,
+ time_zone: column.params.timeZone,
+ useNormalizedEsInterval: !usedField?.aggregationRestrictions?.date_histogram,
+ interval: column.params.interval,
+ drop_partials: false,
+ min_doc_count: 0,
+ extended_bounds: JSON.stringify({}),
+ }).toAst();
},
paramEditor: ({ state, setState, currentColumn, layerId, dateRange, data }) => {
const field =
diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/filters/filters.test.tsx b/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/filters/filters.test.tsx
index 3ac01886537dc..bb8e52ba443a2 100644
--- a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/filters/filters.test.tsx
+++ b/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/filters/filters.test.tsx
@@ -85,25 +85,27 @@ describe('filters', () => {
};
});
- describe('toEsAggsConfig', () => {
+ describe('toEsAggsFn', () => {
it('should reflect params correctly', () => {
- const esAggsConfig = filtersOperation.toEsAggsConfig(
+ const esAggsFn = filtersOperation.toEsAggsFn(
state.layers.first.columns.col1 as FiltersIndexPatternColumn,
'col1',
state.indexPatterns['1']
);
- expect(esAggsConfig).toEqual(
+ expect(esAggsFn).toEqual(
expect.objectContaining({
- params: expect.objectContaining({
+ arguments: expect.objectContaining({
filters: [
- {
- input: { query: 'bytes >= 1', language: 'kuery' },
- label: 'More than one',
- },
- {
- input: { query: 'src : 2', language: 'kuery' },
- label: '',
- },
+ JSON.stringify([
+ {
+ input: { query: 'bytes >= 1', language: 'kuery' },
+ label: 'More than one',
+ },
+ {
+ input: { query: 'src : 2', language: 'kuery' },
+ label: '',
+ },
+ ]),
],
}),
})
diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/filters/filters.tsx b/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/filters/filters.tsx
index c0ae9d59dcd00..b6c0b565f9565 100644
--- a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/filters/filters.tsx
+++ b/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/filters/filters.tsx
@@ -14,7 +14,13 @@ import { OperationDefinition } from '../index';
import { BaseIndexPatternColumn } from '../column_types';
import { FilterPopover } from './filter_popover';
import { IndexPattern } from '../../../types';
-import { Query, esKuery, esQuery } from '../../../../../../../../src/plugins/data/public';
+import {
+ AggFunctionsMapping,
+ Query,
+ esKuery,
+ esQuery,
+} from '../../../../../../../../src/plugins/data/public';
+import { buildExpressionFunction } from '../../../../../../../../src/plugins/expressions/public';
import { NewBucketButton, DragDropBuckets, DraggableBucketContainer } from '../shared_components';
const generateId = htmlIdGenerator();
@@ -110,19 +116,16 @@ export const filtersOperation: OperationDefinition {
+ toEsAggsFn: (column, columnId, indexPattern) => {
const validFilters = column.params.filters?.filter((f: Filter) =>
isQueryValid(f.input, indexPattern)
);
- return {
+ return buildExpressionFunction('aggFilters', {
id: columnId,
enabled: true,
- type: 'filters',
schema: 'segment',
- params: {
- filters: validFilters?.length > 0 ? validFilters : [defaultFilter],
- },
- };
+ filters: JSON.stringify(validFilters?.length > 0 ? validFilters : [defaultFilter]),
+ }).toAst();
},
paramEditor: ({ state, setState, currentColumn, layerId, data }) => {
diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/index.ts b/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/index.ts
index 1bc542376d774..1f19b4e770313 100644
--- a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/index.ts
+++ b/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/index.ts
@@ -4,7 +4,6 @@
* you may not use this file except in compliance with the Elastic License.
*/
-import { ExpressionFunctionAST } from '@kbn/interpreter/common';
import { IUiSettingsClient, SavedObjectsClientContract, HttpSetup } from 'kibana/public';
import { IStorageWrapper } from 'src/plugins/kibana_utils/public';
import { termsOperation, TermsIndexPatternColumn } from './terms';
@@ -44,6 +43,7 @@ import {
IndexPatternLayer,
} from '../../types';
import { DateRange } from '../../../../common';
+import { ExpressionAstFunction } from '../../../../../../../src/plugins/expressions/public';
import { DataPublicPluginStart } from '../../../../../../../src/plugins/data/public';
import { RangeIndexPatternColumn, rangeOperation } from './ranges';
@@ -227,7 +227,7 @@ interface FieldlessOperationDefinition {
* Function turning a column into an agg config passed to the `esaggs` function
* together with the agg configs returned from other columns.
*/
- toEsAggsConfig: (column: C, columnId: string, indexPattern: IndexPattern) => unknown;
+ toEsAggsFn: (column: C, columnId: string, indexPattern: IndexPattern) => ExpressionAstFunction;
}
interface FieldBasedOperationDefinition {
@@ -266,7 +266,7 @@ interface FieldBasedOperationDefinition {
* Function turning a column into an agg config passed to the `esaggs` function
* together with the agg configs returned from other columns.
*/
- toEsAggsConfig: (column: C, columnId: string, indexPattern: IndexPattern) => unknown;
+ toEsAggsFn: (column: C, columnId: string, indexPattern: IndexPattern) => ExpressionAstFunction;
/**
* Validate that the operation has the right preconditions in the state. For example:
*
@@ -329,7 +329,7 @@ interface FullReferenceOperationDefinition {
layer: IndexPatternLayer,
columnId: string,
indexPattern: IndexPattern
- ) => ExpressionFunctionAST[];
+ ) => ExpressionAstFunction[];
}
interface OperationDefinitionMap {
diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/last_value.test.tsx b/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/last_value.test.tsx
index 09b68e78d3469..6c896adfce9b1 100644
--- a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/last_value.test.tsx
+++ b/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/last_value.test.tsx
@@ -74,22 +74,22 @@ describe('last_value', () => {
};
});
- describe('toEsAggsConfig', () => {
+ describe('toEsAggsFn', () => {
it('should reflect params correctly', () => {
const lastValueColumn = state.layers.first.columns.col2 as LastValueIndexPatternColumn;
- const esAggsConfig = lastValueOperation.toEsAggsConfig(
+ const esAggsFn = lastValueOperation.toEsAggsFn(
{ ...lastValueColumn, params: { ...lastValueColumn.params } },
'col1',
{} as IndexPattern
);
- expect(esAggsConfig).toEqual(
+ expect(esAggsFn).toEqual(
expect.objectContaining({
- params: expect.objectContaining({
- aggregate: 'concat',
- field: 'a',
- size: 1,
- sortField: 'datefield',
- sortOrder: 'desc',
+ arguments: expect.objectContaining({
+ aggregate: ['concat'],
+ field: ['a'],
+ size: [1],
+ sortField: ['datefield'],
+ sortOrder: ['desc'],
}),
})
);
diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/last_value.tsx b/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/last_value.tsx
index 5ae5dd472ce22..4cb2d876c83a1 100644
--- a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/last_value.tsx
+++ b/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/last_value.tsx
@@ -6,6 +6,8 @@
import React from 'react';
import { i18n } from '@kbn/i18n';
import { EuiFormRow, EuiComboBox, EuiComboBoxOptionOption } from '@elastic/eui';
+import { AggFunctionsMapping } from '../../../../../../../src/plugins/data/public';
+import { buildExpressionFunction } from '../../../../../../../src/plugins/expressions/public';
import { OperationDefinition } from './index';
import { FieldBasedIndexPatternColumn } from './column_types';
import { IndexPatternField, IndexPattern } from '../../types';
@@ -160,19 +162,18 @@ export const lastValueOperation: OperationDefinition ({
- id: columnId,
- enabled: true,
- schema: 'metric',
- type: 'top_hits',
- params: {
+ toEsAggsFn: (column, columnId) => {
+ return buildExpressionFunction('aggTopHit', {
+ id: columnId,
+ enabled: true,
+ schema: 'metric',
field: column.sourceField,
aggregate: 'concat',
size: 1,
sortOrder: 'desc',
sortField: column.params.sortField,
- },
- }),
+ }).toAst();
+ },
isTransferable: (column, newIndexPattern) => {
const newField = newIndexPattern.getFieldByName(column.sourceField);
diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/metrics.tsx b/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/metrics.tsx
index 10a0b915b552d..bd4f36725f37e 100644
--- a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/metrics.tsx
+++ b/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/metrics.tsx
@@ -5,6 +5,7 @@
*/
import { i18n } from '@kbn/i18n';
+import { buildExpressionFunction } from '../../../../../../../src/plugins/expressions/public';
import { OperationDefinition } from './index';
import { getInvalidFieldMessage } from './helpers';
import {
@@ -22,6 +23,13 @@ type MetricColumn = FormattedIndexPatternColumn &
operationType: T;
};
+const typeToFn: Record = {
+ min: 'aggMin',
+ max: 'aggMax',
+ avg: 'aggAvg',
+ sum: 'aggSum',
+};
+
function buildMetricOperation>({
type,
displayName,
@@ -94,16 +102,14 @@ function buildMetricOperation>({
sourceField: field.name,
};
},
- toEsAggsConfig: (column, columnId, _indexPattern) => ({
- id: columnId,
- enabled: true,
- type: column.operationType,
- schema: 'metric',
- params: {
+ toEsAggsFn: (column, columnId, _indexPattern) => {
+ return buildExpressionFunction(typeToFn[type], {
+ id: columnId,
+ enabled: true,
+ schema: 'metric',
field: column.sourceField,
- missing: 0,
- },
- }),
+ }).toAst();
+ },
getErrorMessage: (layer, columnId, indexPattern) =>
getInvalidFieldMessage(layer.columns[columnId] as FieldBasedIndexPatternColumn, indexPattern),
} as OperationDefinition;
diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/ranges/ranges.test.tsx b/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/ranges/ranges.test.tsx
index 87dcdb45cf58f..82ead5a6f3962 100644
--- a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/ranges/ranges.test.tsx
+++ b/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/ranges/ranges.test.tsx
@@ -145,21 +145,63 @@ describe('ranges', () => {
state = getDefaultState();
});
- describe('toEsAggConfig', () => {
+ describe('toEsAggsFn', () => {
afterAll(() => setToHistogramMode());
it('should reflect params correctly', () => {
- const esAggsConfig = rangeOperation.toEsAggsConfig(
+ const esAggsFn = rangeOperation.toEsAggsFn(
state.layers.first.columns.col1 as RangeIndexPatternColumn,
'col1',
{} as IndexPattern
);
- expect(esAggsConfig).toEqual(
+ expect(esAggsFn).toMatchInlineSnapshot(`
+ Object {
+ "arguments": Object {
+ "enabled": Array [
+ true,
+ ],
+ "extended_bounds": Array [
+ "{\\"min\\":\\"\\",\\"max\\":\\"\\"}",
+ ],
+ "field": Array [
+ "MyField",
+ ],
+ "has_extended_bounds": Array [
+ false,
+ ],
+ "id": Array [
+ "col1",
+ ],
+ "interval": Array [
+ "auto",
+ ],
+ "min_doc_count": Array [
+ false,
+ ],
+ "schema": Array [
+ "segment",
+ ],
+ },
+ "function": "aggHistogram",
+ "type": "function",
+ }
+ `);
+ });
+
+ it('should set maxBars param if provided', () => {
+ (state.layers.first.columns.col1 as RangeIndexPatternColumn).params.maxBars = 10;
+
+ const esAggsFn = rangeOperation.toEsAggsFn(
+ state.layers.first.columns.col1 as RangeIndexPatternColumn,
+ 'col1',
+ {} as IndexPattern
+ );
+
+ expect(esAggsFn).toEqual(
expect.objectContaining({
- type: MODES.Histogram,
- params: expect.objectContaining({
- field: sourceField,
- maxBars: null,
+ function: 'aggHistogram',
+ arguments: expect.objectContaining({
+ maxBars: [10],
}),
})
);
@@ -168,15 +210,15 @@ describe('ranges', () => {
it('should reflect the type correctly', () => {
setToRangeMode();
- const esAggsConfig = rangeOperation.toEsAggsConfig(
+ const esAggsFn = rangeOperation.toEsAggsFn(
state.layers.first.columns.col1 as RangeIndexPatternColumn,
'col1',
{} as IndexPattern
);
- expect(esAggsConfig).toEqual(
+ expect(esAggsFn).toEqual(
expect.objectContaining({
- type: MODES.Range,
+ function: 'aggRange',
})
);
});
@@ -187,15 +229,15 @@ describe('ranges', () => {
{ from: 0, to: 100, label: 'customlabel' },
];
- const esAggsConfig = rangeOperation.toEsAggsConfig(
+ const esAggsFn = rangeOperation.toEsAggsFn(
state.layers.first.columns.col1 as RangeIndexPatternColumn,
'col1',
{} as IndexPattern
);
- expect((esAggsConfig as { params: unknown }).params).toEqual(
+ expect((esAggsFn as { arguments: unknown }).arguments).toEqual(
expect.objectContaining({
- ranges: [{ from: 0, to: 100, label: 'customlabel' }],
+ ranges: [JSON.stringify([{ from: 0, to: 100, label: 'customlabel' }])],
})
);
});
diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/ranges/ranges.tsx b/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/ranges/ranges.tsx
index f2d3435cc52c0..062e2afb8a5bf 100644
--- a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/ranges/ranges.tsx
+++ b/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/ranges/ranges.tsx
@@ -7,8 +7,11 @@
import React from 'react';
import { i18n } from '@kbn/i18n';
-import { UI_SETTINGS } from '../../../../../../../../src/plugins/data/common';
-import { Range } from '../../../../../../../../src/plugins/expressions/common/expression_types/index';
+import { AggFunctionsMapping, UI_SETTINGS } from '../../../../../../../../src/plugins/data/public';
+import {
+ buildExpressionFunction,
+ Range,
+} from '../../../../../../../../src/plugins/expressions/public';
import { RangeEditor } from './range_editor';
import { OperationDefinition } from '../index';
import { FieldBasedIndexPatternColumn } from '../column_types';
@@ -73,36 +76,6 @@ function getFieldDefaultFormat(indexPattern: IndexPattern, field: IndexPatternFi
return undefined;
}
-function getEsAggsParams({ sourceField, params }: RangeIndexPatternColumn) {
- if (params.type === MODES.Range) {
- return {
- field: sourceField,
- ranges: params.ranges.filter(isValidRange).map>((range) => {
- if (isFullRange(range)) {
- return range;
- }
- const partialRange: Partial = { label: range.label };
- // be careful with the fields to set on partial ranges
- if (isValidNumber(range.from)) {
- partialRange.from = range.from;
- }
- if (isValidNumber(range.to)) {
- partialRange.to = range.to;
- }
- return partialRange;
- }),
- };
- }
- return {
- field: sourceField,
- // fallback to 0 in case of empty string
- maxBars: params.maxBars === AUTO_BARS ? null : params.maxBars,
- has_extended_bounds: false,
- min_doc_count: 0,
- extended_bounds: { min: '', max: '' },
- };
-}
-
export const rangeOperation: OperationDefinition = {
type: 'range',
displayName: i18n.translate('xpack.lens.indexPattern.intervals', {
@@ -161,15 +134,44 @@ export const rangeOperation: OperationDefinition {
- const params = getEsAggsParams(column);
- return {
+ toEsAggsFn: (column, columnId) => {
+ const { sourceField, params } = column;
+ if (params.type === MODES.Range) {
+ return buildExpressionFunction('aggRange', {
+ id: columnId,
+ enabled: true,
+ schema: 'segment',
+ field: sourceField,
+ ranges: JSON.stringify(
+ params.ranges.filter(isValidRange).map>((range) => {
+ if (isFullRange(range)) {
+ return range;
+ }
+ const partialRange: Partial = { label: range.label };
+ // be careful with the fields to set on partial ranges
+ if (isValidNumber(range.from)) {
+ partialRange.from = range.from;
+ }
+ if (isValidNumber(range.to)) {
+ partialRange.to = range.to;
+ }
+ return partialRange;
+ })
+ ),
+ }).toAst();
+ }
+ return buildExpressionFunction('aggHistogram', {
id: columnId,
enabled: true,
- type: column.params.type,
schema: 'segment',
- params,
- };
+ field: sourceField,
+ // fallback to 0 in case of empty string
+ maxBars: params.maxBars === AUTO_BARS ? undefined : params.maxBars,
+ interval: 'auto',
+ has_extended_bounds: false,
+ min_doc_count: false,
+ extended_bounds: JSON.stringify({ min: '', max: '' }),
+ }).toAst();
},
paramEditor: ({ state, setState, currentColumn, layerId, columnId, uiSettings, data }) => {
const indexPattern = state.indexPatterns[state.layers[layerId].indexPatternId];
diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/terms/index.tsx b/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/terms/index.tsx
index e8351ea1e1d09..1e2d800cb3e80 100644
--- a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/terms/index.tsx
+++ b/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/terms/index.tsx
@@ -16,6 +16,8 @@ import {
EuiButtonEmpty,
EuiText,
} from '@elastic/eui';
+import { AggFunctionsMapping } from '../../../../../../../../src/plugins/data/public';
+import { buildExpressionFunction } from '../../../../../../../../src/plugins/expressions/public';
import { IndexPatternColumn } from '../../../indexpattern';
import { updateColumnParam, isReferenced } from '../../layer_helpers';
import { DataType } from '../../../../types';
@@ -114,28 +116,25 @@ export const termsOperation: OperationDefinition