Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SavedObjects] Add aggregations support #96292

Merged
merged 76 commits into from
Apr 16, 2021
Merged
Show file tree
Hide file tree
Changes from 72 commits
Commits
Show all changes
76 commits
Select commit Hold shift + click to select a range
b699c70
step 1 to add aggs in the find function of saved object
XavierM Apr 14, 2020
3819cd5
setp 2 - add specific unit test to aggs + fix bug found during integr…
XavierM Apr 15, 2020
1c4bac9
step 3 - add security api_integration arounds aggs
XavierM Apr 20, 2020
6feca9b
fix types
XavierM Apr 20, 2020
8dda821
unit test added for aggs_utils
XavierM Apr 20, 2020
0904a0e
Merge branch 'master' of github.com:elastic/kibana into saved-objects…
XavierM Apr 20, 2020
44dcb25
add documentation
XavierM Apr 22, 2020
560b63b
Merge branch 'master' of github.com:elastic/kibana into saved-objects…
XavierM Apr 22, 2020
699d0a1
Merge branch 'master' of github.com:elastic/kibana into saved-objects…
XavierM Apr 27, 2020
0f57677
fix docs
XavierM Apr 27, 2020
d7cb38e
Merge branch 'master' of github.com:elastic/kibana into saved-objects…
XavierM Apr 27, 2020
ec2a69d
Merge branch 'master' of github.com:elastic/kibana into saved-objects…
XavierM Jul 6, 2020
817a3ef
review I
XavierM Jul 7, 2020
f7faa18
Merge branch 'master' of github.com:elastic/kibana into saved-objects…
XavierM Jul 7, 2020
a54f440
doc
XavierM Jul 7, 2020
2aef7fd
Merge branch 'master' of github.com:elastic/kibana into saved-objects…
XavierM Jul 7, 2020
e698b0e
try to fix test
XavierM Jul 7, 2020
09565d8
Merge branch 'master' of github.com:elastic/kibana into saved-objects…
XavierM Jul 7, 2020
c16e72b
add the new property to the saved object globaltype
XavierM Jul 7, 2020
5a12d44
fix types
XavierM Jul 7, 2020
c4eff53
Merge branch 'master' of github.com:elastic/kibana into saved-objects…
XavierM Jul 7, 2020
1eaafca
Merge branch 'master' of github.com:elastic/kibana into saved-objects…
XavierM Nov 9, 2020
f04ab64
delete old files
XavierM Nov 9, 2020
8f64144
fix types + test api integration
XavierM Nov 9, 2020
2209d12
type fix + test
XavierM Nov 10, 2020
4f667d4
Update src/core/server/saved_objects/types.ts
XavierM Nov 11, 2020
433a71c
review I
XavierM Nov 11, 2020
37ad64d
Merge branch 'saved-objects-aggs' of github.com:XavierM/kibana into s…
XavierM Nov 11, 2020
2fb9a2c
Merge branch 'master' of github.com:elastic/kibana into saved-objects…
XavierM Nov 11, 2020
48dcdda
Merge branch 'master' into saved-objects-aggs
kibanamachine Nov 11, 2020
2dc3ff8
Merge branch 'master' into saved-objects-aggs
kibanamachine Nov 12, 2020
f1f437b
Merge branch 'master' of github.com:elastic/kibana into saved-objects…
XavierM Nov 20, 2020
b23eac7
change our validation to match discussion with Pierre and Rudolph
XavierM Nov 23, 2020
462d87e
Merge branch 'master' of github.com:elastic/kibana into saved-objects…
XavierM Nov 23, 2020
4e319b3
Validate multiple items nested filter query through KueryNode
XavierM Nov 23, 2020
ba55542
Merge branch 'master' of github.com:elastic/kibana into saved-objects…
XavierM Nov 23, 2020
16de875
remove unused import
XavierM Nov 23, 2020
cb7ada3
review + put back test
XavierM Nov 23, 2020
3ce2a4d
Merge remote-tracking branch 'upstream/master' into kbn-xxx-SO-aggrs-…
pgayvallet Apr 6, 2021
b88bbbd
migrate added tests to new TS file
pgayvallet Apr 6, 2021
3682d30
fix documentation
pgayvallet Apr 6, 2021
3d37556
fix license header
pgayvallet Apr 6, 2021
fa35f93
move stuff
pgayvallet Apr 6, 2021
3efad5b
duplicating test mappings
pgayvallet Apr 6, 2021
af2b743
rename some stuff
pgayvallet Apr 6, 2021
2bb16d0
move ALL the things
pgayvallet Apr 6, 2021
e150741
cast to aggregation container
pgayvallet Apr 6, 2021
f60cb6f
update generated doc
pgayvallet Apr 6, 2021
2efb54c
add deep nested validation
pgayvallet Apr 6, 2021
4adf27d
rewrite the whole validation mechanism
pgayvallet Apr 7, 2021
bfb812d
some cleanup
pgayvallet Apr 7, 2021
5514d77
Merge remote-tracking branch 'upstream/master' into kbn-xxx-SO-aggrs-…
pgayvallet Apr 7, 2021
62d3d69
minor cleanup
pgayvallet Apr 7, 2021
4e2ae77
update generated doc
pgayvallet Apr 7, 2021
4bae5b9
adapt telemetry client
pgayvallet Apr 7, 2021
2279447
fix API integ tests
pgayvallet Apr 7, 2021
8099f36
fix doc
pgayvallet Apr 7, 2021
ecc8d2d
TOTO-less
pgayvallet Apr 7, 2021
08ce7d5
remove xpack tests
pgayvallet Apr 7, 2021
2aef2d8
list supported / unsupported aggregations
pgayvallet Apr 7, 2021
0ffe804
typo fix
pgayvallet Apr 7, 2021
90dc2a1
extract some validation function
pgayvallet Apr 7, 2021
ccc50df
fix indent
pgayvallet Apr 7, 2021
eda6b74
add some unit tests
pgayvallet Apr 7, 2021
4d4b377
Merge remote-tracking branch 'upstream/master' into kbn-xxx-SO-aggrs-…
pgayvallet Apr 7, 2021
c8c8bec
Merge remote-tracking branch 'upstream/master' into kbn-xxx-SO-aggrs-…
pgayvallet Apr 8, 2021
5d0e352
adapt FTR assertions
pgayvallet Apr 8, 2021
8d9e41f
update doc
pgayvallet Apr 8, 2021
5c6d3ac
fix doc
pgayvallet Apr 8, 2021
c167987
doc again
pgayvallet Apr 8, 2021
5239a44
cleanup test names
pgayvallet Apr 8, 2021
cb0327c
improve tsdoc on validation functions
pgayvallet Apr 8, 2021
705fe34
Merge remote-tracking branch 'upstream/master' into kbn-xxx-SO-aggrs-…
pgayvallet Apr 12, 2021
fba668e
perf nit
pgayvallet Apr 12, 2021
96f6a86
Merge remote-tracking branch 'upstream/master' into kbn-xxx-SO-aggrs-…
pgayvallet Apr 14, 2021
1adf244
Merge remote-tracking branch 'upstream/master' into kbn-xxx-SO-aggrs-…
pgayvallet Apr 16, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions docs/api/saved-objects/find.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,14 @@ experimental[] Retrieve a paginated set of {kib} saved objects by various condit
(Optional, object) Filters to objects that have a relationship with the type and ID combination.

`filter`::
(Optional, string) The filter is a KQL string with the caveat that if you filter with an attribute from your type saved object.
It should look like that savedObjectType.attributes.title: "myTitle". However, If you used a direct attribute of a saved object like `updatedAt`,
you will have to define your filter like that savedObjectType.updatedAt > 2018-12-22.
(Optional, string) The filter is a KQL string with the caveat that if you filter with an attribute from your saved object type,
it should look like that: `savedObjectType.attributes.title: "myTitle"`. However, If you use a root attribute of a saved
object such as `updated_at`, you will have to define your filter like that: `savedObjectType.updated_at > 2018-12-22`.

`aggs`::
(Optional, string) **experimental** An aggregation structure, serialized as a string. The field format is similar to `filter`, meaning
that to use a saved object type attribute in the aggregation, the `savedObjectType.attributes.title`: "myTitle"` format
must be used. For root fields, the syntax is `savedObjectType.rootField`

NOTE: As objects change in {kib}, the results on each page of the response also
change. Use the find API for traditional paginated results, but avoid using it to export large amounts of data.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ Search for objects
<b>Signature:</b>

```typescript
find: <T = unknown>(options: SavedObjectsFindOptions) => Promise<SavedObjectsFindResponsePublic<T>>;
find: <T = unknown, A = unknown>(options: SavedObjectsFindOptions) => Promise<SavedObjectsFindResponsePublic<T, unknown>>;
```
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ The constructor for this class is marked as internal. Third-party code should no
| [bulkGet](./kibana-plugin-core-public.savedobjectsclient.bulkget.md) | | <code>(objects?: Array&lt;{</code><br/><code> id: string;</code><br/><code> type: string;</code><br/><code> }&gt;) =&gt; Promise&lt;SavedObjectsBatchResponse&lt;unknown&gt;&gt;</code> | Returns an array of objects by id |
| [create](./kibana-plugin-core-public.savedobjectsclient.create.md) | | <code>&lt;T = unknown&gt;(type: string, attributes: T, options?: SavedObjectsCreateOptions) =&gt; Promise&lt;SimpleSavedObject&lt;T&gt;&gt;</code> | Persists an object |
| [delete](./kibana-plugin-core-public.savedobjectsclient.delete.md) | | <code>(type: string, id: string, options?: SavedObjectsDeleteOptions &#124; undefined) =&gt; ReturnType&lt;SavedObjectsApi['delete']&gt;</code> | Deletes an object |
| [find](./kibana-plugin-core-public.savedobjectsclient.find.md) | | <code>&lt;T = unknown&gt;(options: SavedObjectsFindOptions) =&gt; Promise&lt;SavedObjectsFindResponsePublic&lt;T&gt;&gt;</code> | Search for objects |
| [find](./kibana-plugin-core-public.savedobjectsclient.find.md) | | <code>&lt;T = unknown, A = unknown&gt;(options: SavedObjectsFindOptions) =&gt; Promise&lt;SavedObjectsFindResponsePublic&lt;T, unknown&gt;&gt;</code> | Search for objects |
| [get](./kibana-plugin-core-public.savedobjectsclient.get.md) | | <code>&lt;T = unknown&gt;(type: string, id: string) =&gt; Promise&lt;SimpleSavedObject&lt;T&gt;&gt;</code> | Fetches a single object |

## Methods
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-core-public](./kibana-plugin-core-public.md) &gt; [SavedObjectsFindResponsePublic](./kibana-plugin-core-public.savedobjectsfindresponsepublic.md) &gt; [aggregations](./kibana-plugin-core-public.savedobjectsfindresponsepublic.aggregations.md)

## SavedObjectsFindResponsePublic.aggregations property

<b>Signature:</b>

```typescript
aggregations?: A;
```
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,14 @@ Return type of the Saved Objects `find()` method.
<b>Signature:</b>

```typescript
export interface SavedObjectsFindResponsePublic<T = unknown> extends SavedObjectsBatchResponse<T>
export interface SavedObjectsFindResponsePublic<T = unknown, A = unknown> extends SavedObjectsBatchResponse<T>
```

## Properties

| Property | Type | Description |
| --- | --- | --- |
| [aggregations](./kibana-plugin-core-public.savedobjectsfindresponsepublic.aggregations.md) | <code>A</code> | |
| [page](./kibana-plugin-core-public.savedobjectsfindresponsepublic.page.md) | <code>number</code> | |
| [perPage](./kibana-plugin-core-public.savedobjectsfindresponsepublic.perpage.md) | <code>number</code> | |
| [total](./kibana-plugin-core-public.savedobjectsfindresponsepublic.total.md) | <code>number</code> | |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Find all SavedObjects matching the search query
<b>Signature:</b>

```typescript
find<T = unknown>(options: SavedObjectsFindOptions): Promise<SavedObjectsFindResponse<T>>;
find<T = unknown, A = unknown>(options: SavedObjectsFindOptions): Promise<SavedObjectsFindResponse<T, A>>;
```

## Parameters
Expand All @@ -20,5 +20,5 @@ find<T = unknown>(options: SavedObjectsFindOptions): Promise<SavedObjectsFindRes

<b>Returns:</b>

`Promise<SavedObjectsFindResponse<T>>`
`Promise<SavedObjectsFindResponse<T, A>>`

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-core-server](./kibana-plugin-core-server.md) &gt; [SavedObjectsFindResponse](./kibana-plugin-core-server.savedobjectsfindresponse.md) &gt; [aggregations](./kibana-plugin-core-server.savedobjectsfindresponse.aggregations.md)

## SavedObjectsFindResponse.aggregations property

<b>Signature:</b>

```typescript
aggregations?: A;
```
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,14 @@ Return type of the Saved Objects `find()` method.
<b>Signature:</b>

```typescript
export interface SavedObjectsFindResponse<T = unknown>
export interface SavedObjectsFindResponse<T = unknown, A = unknown>
```

## Properties

| Property | Type | Description |
| --- | --- | --- |
| [aggregations](./kibana-plugin-core-server.savedobjectsfindresponse.aggregations.md) | <code>A</code> | |
| [page](./kibana-plugin-core-server.savedobjectsfindresponse.page.md) | <code>number</code> | |
| [per\_page](./kibana-plugin-core-server.savedobjectsfindresponse.per_page.md) | <code>number</code> | |
| [pit\_id](./kibana-plugin-core-server.savedobjectsfindresponse.pit_id.md) | <code>string</code> | |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<b>Signature:</b>

```typescript
find<T = unknown>(options: SavedObjectsFindOptions): Promise<SavedObjectsFindResponse<T>>;
find<T = unknown, A = unknown>(options: SavedObjectsFindOptions): Promise<SavedObjectsFindResponse<T, A>>;
```

## Parameters
Expand All @@ -18,7 +18,7 @@ find<T = unknown>(options: SavedObjectsFindOptions): Promise<SavedObjectsFindRes

<b>Returns:</b>

`Promise<SavedObjectsFindResponse<T>>`
`Promise<SavedObjectsFindResponse<T, A>>`

{<!-- -->promise<!-- -->} - { saved\_objects: \[{ id, type, version, attributes }<!-- -->\], total, per\_page, page }

Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ Creates an empty response for a find operation. This is only intended to be used
<b>Signature:</b>

```typescript
static createEmptyFindResponse: <T>({ page, perPage, }: SavedObjectsFindOptions) => SavedObjectsFindResponse<T>;
static createEmptyFindResponse: <T, A>({ page, perPage, }: SavedObjectsFindOptions) => SavedObjectsFindResponse<T, A>;
```
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export declare class SavedObjectsUtils

| Property | Modifiers | Type | Description |
| --- | --- | --- | --- |
| [createEmptyFindResponse](./kibana-plugin-core-server.savedobjectsutils.createemptyfindresponse.md) | <code>static</code> | <code>&lt;T&gt;({ page, perPage, }: SavedObjectsFindOptions) =&gt; SavedObjectsFindResponse&lt;T&gt;</code> | Creates an empty response for a find operation. This is only intended to be used by saved objects client wrappers. |
| [createEmptyFindResponse](./kibana-plugin-core-server.savedobjectsutils.createemptyfindresponse.md) | <code>static</code> | <code>&lt;T, A&gt;({ page, perPage, }: SavedObjectsFindOptions) =&gt; SavedObjectsFindResponse&lt;T, A&gt;</code> | Creates an empty response for a find operation. This is only intended to be used by saved objects client wrappers. |
| [namespaceIdToString](./kibana-plugin-core-server.savedobjectsutils.namespaceidtostring.md) | <code>static</code> | <code>(namespace?: string &#124; undefined) =&gt; string</code> | Converts a given saved object namespace ID to its string representation. All namespace IDs have an identical string representation, with the exception of the <code>undefined</code> namespace ID (which has a namespace string of <code>'default'</code>). |
| [namespaceStringToId](./kibana-plugin-core-server.savedobjectsutils.namespacestringtoid.md) | <code>static</code> | <code>(namespace: string) =&gt; string &#124; undefined</code> | Converts a given saved object namespace string to its ID representation. All namespace strings have an identical ID representation, with the exception of the <code>'default'</code> namespace string (which has a namespace ID of <code>undefined</code>). |

Expand Down
8 changes: 6 additions & 2 deletions src/core/public/public.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -1210,7 +1210,7 @@ export class SavedObjectsClient {
// Warning: (ae-forgotten-export) The symbol "SavedObjectsClientContract" needs to be exported by the entry point index.d.ts
delete: (type: string, id: string, options?: SavedObjectsDeleteOptions | undefined) => ReturnType<SavedObjectsClientContract_2['delete']>;
// Warning: (ae-forgotten-export) The symbol "SavedObjectsFindOptions" needs to be exported by the entry point index.d.ts
find: <T = unknown>(options: SavedObjectsFindOptions_2) => Promise<SavedObjectsFindResponsePublic<T>>;
find: <T = unknown, A = unknown>(options: SavedObjectsFindOptions_2) => Promise<SavedObjectsFindResponsePublic<T, unknown>>;
get: <T = unknown>(type: string, id: string) => Promise<SimpleSavedObject<T>>;
update<T = unknown>(type: string, id: string, attributes: T, { version, migrationVersion, references }?: SavedObjectsUpdateOptions): Promise<SimpleSavedObject<T>>;
}
Expand All @@ -1230,6 +1230,8 @@ export interface SavedObjectsCreateOptions {

// @public (undocumented)
export interface SavedObjectsFindOptions {
// @alpha
aggs?: Record<string, estypes.AggregationContainer>;
defaultSearchOperator?: 'AND' | 'OR';
fields?: string[];
// Warning: (ae-forgotten-export) The symbol "KueryNode" needs to be exported by the entry point index.d.ts
Expand Down Expand Up @@ -1270,7 +1272,9 @@ export interface SavedObjectsFindOptionsReference {
}

// @public
export interface SavedObjectsFindResponsePublic<T = unknown> extends SavedObjectsBatchResponse<T> {
export interface SavedObjectsFindResponsePublic<T = unknown, A = unknown> extends SavedObjectsBatchResponse<T> {
// (undocumented)
aggregations?: A;
// (undocumented)
page: number;
// (undocumented)
Expand Down
14 changes: 12 additions & 2 deletions src/core/public/saved_objects/saved_objects_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,9 @@ export interface SavedObjectsDeleteOptions {
*
* @public
*/
export interface SavedObjectsFindResponsePublic<T = unknown> extends SavedObjectsBatchResponse<T> {
export interface SavedObjectsFindResponsePublic<T = unknown, A = unknown>
extends SavedObjectsBatchResponse<T> {
aggregations?: A;
total: number;
perPage: number;
page: number;
Expand Down Expand Up @@ -310,7 +312,7 @@ export class SavedObjectsClient {
* @property {object} [options.hasReference] - { type, id }
* @returns A find result with objects matching the specified search.
*/
public find = <T = unknown>(
public find = <T = unknown, A = unknown>(
options: SavedObjectsFindOptions
): Promise<SavedObjectsFindResponsePublic<T>> => {
const path = this.getPath(['_find']);
Expand All @@ -326,6 +328,7 @@ export class SavedObjectsClient {
sortField: 'sort_field',
type: 'type',
filter: 'filter',
aggs: 'aggs',
namespaces: 'namespaces',
preference: 'preference',
};
Expand All @@ -342,13 +345,20 @@ export class SavedObjectsClient {
query.has_reference = JSON.stringify(query.has_reference);
}

// `aggs` is a structured object. we need to stringify it before sending it, as `fetch`
// is not doing it implicitly.
if (query.aggs) {
query.aggs = JSON.stringify(query.aggs);
}

const request: ReturnType<SavedObjectsApi['find']> = this.savedObjectsFetch(path, {
method: 'GET',
query,
});
return request.then((resp) => {
return renameKeys<SavedObjectsFindResponse, SavedObjectsFindResponsePublic>(
{
aggregations: 'aggregations',
saved_objects: 'savedObjects',
total: 'total',
per_page: 'perPage',
Expand Down
16 changes: 16 additions & 0 deletions src/core/server/saved_objects/routes/find.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export const registerFindRoute = (router: IRouter, { coreUsageData }: RouteDepen
has_reference_operator: searchOperatorSchema,
fields: schema.maybe(schema.oneOf([schema.string(), schema.arrayOf(schema.string())])),
filter: schema.maybe(schema.string()),
aggs: schema.maybe(schema.string()),
namespaces: schema.maybe(
schema.oneOf([schema.string(), schema.arrayOf(schema.string())])
),
Expand All @@ -59,6 +60,20 @@ export const registerFindRoute = (router: IRouter, { coreUsageData }: RouteDepen
const usageStatsClient = coreUsageData.getClient();
usageStatsClient.incrementSavedObjectsFind({ request: req }).catch(() => {});

// manually validation to avoid using JSON.parse twice
let aggs;
if (query.aggs) {
try {
aggs = JSON.parse(query.aggs);
} catch (e) {
return res.badRequest({
body: {
message: 'invalid aggs value',
},
});
}
}

const result = await context.core.savedObjects.client.find({
perPage: query.per_page,
page: query.page,
Expand All @@ -72,6 +87,7 @@ export const registerFindRoute = (router: IRouter, { coreUsageData }: RouteDepen
hasReferenceOperator: query.has_reference_operator,
fields: typeof query.fields === 'string' ? [query.fields] : query.fields,
filter: query.filter,
aggs,
namespaces,
});

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

import { schema as s, ObjectType } from '@kbn/config-schema';

/**
* Schemas for the Bucket aggregations.
*
* Currently supported:
* - filter
* - histogram
* - terms
*
* Not implemented:
* - adjacency_matrix
* - auto_date_histogram
* - children
* - composite
* - date_histogram
* - date_range
* - diversified_sampler
* - filters
* - geo_distance
* - geohash_grid
* - geotile_grid
* - global
* - ip_range
* - missing
* - multi_terms
* - nested
* - parent
* - range
* - rare_terms
* - reverse_nested
* - sampler
* - significant_terms
* - significant_text
* - variable_width_histogram
*/
export const bucketAggsSchemas: Record<string, ObjectType> = {
filter: s.object({
term: s.recordOf(s.string(), s.oneOf([s.string(), s.boolean(), s.number()])),
}),
histogram: s.object({
field: s.maybe(s.string()),
interval: s.maybe(s.number()),
Comment on lines +46 to +51
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some fields / shapes could easily be factorized (e.g extended_bounds and hard_bounds are the same TS type in AggregationContainer), but I'd rather do that later when we'll get some feedback on the usability of the API.

min_doc_count: s.maybe(s.number()),
extended_bounds: s.maybe(
s.object({
min: s.number(),
max: s.number(),
})
),
hard_bounds: s.maybe(
s.object({
min: s.number(),
max: s.number(),
})
),
missing: s.maybe(s.number()),
keyed: s.maybe(s.boolean()),
order: s.maybe(
s.object({
_count: s.string(),
_key: s.string(),
})
),
}),
terms: s.object({
field: s.maybe(s.string()),
collect_mode: s.maybe(s.string()),
exclude: s.maybe(s.oneOf([s.string(), s.arrayOf(s.string())])),
include: s.maybe(s.oneOf([s.string(), s.arrayOf(s.string())])),
execution_hint: s.maybe(s.string()),
missing: s.maybe(s.number()),
min_doc_count: s.maybe(s.number()),
size: s.maybe(s.number()),
show_term_doc_count_error: s.maybe(s.boolean()),
order: s.maybe(s.oneOf([s.literal('asc'), s.literal('desc')])),
}),
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

import { bucketAggsSchemas } from './bucket_aggs';
import { metricsAggsSchemas } from './metrics_aggs';

export const aggregationSchemas = {
...metricsAggsSchemas,
...bucketAggsSchemas,
};
Loading