diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpatternsservice.getfieldsforindexpattern.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpatternsservice.getfieldsforindexpattern.md
index c06c3c6f68492..f288573cd7abb 100644
--- a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpatternsservice.getfieldsforindexpattern.md
+++ b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpatternsservice.getfieldsforindexpattern.md
@@ -9,5 +9,5 @@ Get field list by providing an index patttern (or spec)
Signature:
```typescript
-getFieldsForIndexPattern: (indexPattern: IndexPattern | IndexPatternSpec, options?: GetFieldsOptions) => Promise;
+getFieldsForIndexPattern: (indexPattern: IndexPattern | IndexPatternSpec, options?: GetFieldsOptions | undefined) => Promise;
```
diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpatternsservice.getfieldsforwildcard.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpatternsservice.getfieldsforwildcard.md
index aec84866b9e58..32bf6fc13b02c 100644
--- a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpatternsservice.getfieldsforwildcard.md
+++ b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpatternsservice.getfieldsforwildcard.md
@@ -9,5 +9,5 @@ Get field list by providing { pattern }
Signature:
```typescript
-getFieldsForWildcard: (options?: GetFieldsOptions) => Promise;
+getFieldsForWildcard: (options: GetFieldsOptions) => Promise;
```
diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpatternsservice.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpatternsservice.md
index 34df8656e9175..57bb98de09ebd 100644
--- a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpatternsservice.md
+++ b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpatternsservice.md
@@ -26,8 +26,8 @@ export declare class IndexPatternsService
| [get](./kibana-plugin-plugins-data-public.indexpatternsservice.get.md) | | (id: string) => Promise<IndexPattern>
| Get an index pattern by id. Cache optimized |
| [getCache](./kibana-plugin-plugins-data-public.indexpatternsservice.getcache.md) | | () => Promise<SavedObject<IndexPatternSavedObjectAttrs>[] | null | undefined>
| |
| [getDefault](./kibana-plugin-plugins-data-public.indexpatternsservice.getdefault.md) | | () => Promise<IndexPattern | null>
| Get default index pattern |
-| [getFieldsForIndexPattern](./kibana-plugin-plugins-data-public.indexpatternsservice.getfieldsforindexpattern.md) | | (indexPattern: IndexPattern | IndexPatternSpec, options?: GetFieldsOptions) => Promise<any>
| Get field list by providing an index patttern (or spec) |
-| [getFieldsForWildcard](./kibana-plugin-plugins-data-public.indexpatternsservice.getfieldsforwildcard.md) | | (options?: GetFieldsOptions) => Promise<any>
| Get field list by providing { pattern } |
+| [getFieldsForIndexPattern](./kibana-plugin-plugins-data-public.indexpatternsservice.getfieldsforindexpattern.md) | | (indexPattern: IndexPattern | IndexPatternSpec, options?: GetFieldsOptions | undefined) => Promise<any>
| Get field list by providing an index patttern (or spec) |
+| [getFieldsForWildcard](./kibana-plugin-plugins-data-public.indexpatternsservice.getfieldsforwildcard.md) | | (options: GetFieldsOptions) => Promise<any>
| Get field list by providing { pattern } |
| [getIds](./kibana-plugin-plugins-data-public.indexpatternsservice.getids.md) | | (refresh?: boolean) => Promise<string[]>
| Get list of index pattern ids |
| [getIdsWithTitle](./kibana-plugin-plugins-data-public.indexpatternsservice.getidswithtitle.md) | | (refresh?: boolean) => Promise<Array<{
id: string;
title: string;
}>>
| Get list of index pattern ids with titles |
| [getTitles](./kibana-plugin-plugins-data-public.indexpatternsservice.gettitles.md) | | (refresh?: boolean) => Promise<string[]>
| Get list of index pattern titles |
diff --git a/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.getcapabilitiesforrollupindices.md b/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.getcapabilitiesforrollupindices.md
new file mode 100644
index 0000000000000..ba2efcc9b75ca
--- /dev/null
+++ b/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.getcapabilitiesforrollupindices.md
@@ -0,0 +1,28 @@
+
+
+[Home](./index.md) > [kibana-plugin-plugins-data-server](./kibana-plugin-plugins-data-server.md) > [getCapabilitiesForRollupIndices](./kibana-plugin-plugins-data-server.getcapabilitiesforrollupindices.md)
+
+## getCapabilitiesForRollupIndices() function
+
+Signature:
+
+```typescript
+export declare function getCapabilitiesForRollupIndices(indices: {
+ [key: string]: any;
+}): {
+ [key: string]: any;
+};
+```
+
+## Parameters
+
+| Parameter | Type | Description |
+| --- | --- | --- |
+| indices | {
[key: string]: any;
}
| |
+
+Returns:
+
+`{
+ [key: string]: any;
+}`
+
diff --git a/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.indexpatternsfetcher.getfieldsforwildcard.md b/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.indexpatternsfetcher.getfieldsforwildcard.md
index addd29916d81d..f0989097a727d 100644
--- a/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.indexpatternsfetcher.getfieldsforwildcard.md
+++ b/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.indexpatternsfetcher.getfieldsforwildcard.md
@@ -15,6 +15,8 @@ getFieldsForWildcard(options: {
fieldCapsOptions?: {
allow_no_indices: boolean;
};
+ type?: string;
+ rollupIndex?: string;
}): Promise;
```
@@ -22,7 +24,7 @@ getFieldsForWildcard(options: {
| Parameter | Type | Description |
| --- | --- | --- |
-| options | {
pattern: string | string[];
metaFields?: string[];
fieldCapsOptions?: {
allow_no_indices: boolean;
};
}
| |
+| options | {
pattern: string | string[];
metaFields?: string[];
fieldCapsOptions?: {
allow_no_indices: boolean;
};
type?: string;
rollupIndex?: string;
}
| |
Returns:
diff --git a/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.indexpatternsservice.start.md b/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.indexpatternsservice.start.md
index e7c331bad64e8..6528b1c213cca 100644
--- a/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.indexpatternsservice.start.md
+++ b/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.indexpatternsservice.start.md
@@ -8,7 +8,7 @@
```typescript
start(core: CoreStart, { fieldFormats, logger }: IndexPatternsServiceStartDeps): {
- indexPatternsServiceFactory: (savedObjectsClient: SavedObjectsClientContract) => Promise;
+ indexPatternsServiceFactory: (savedObjectsClient: SavedObjectsClientContract, elasticsearchClient: ElasticsearchClient) => Promise;
};
```
@@ -22,6 +22,6 @@ start(core: CoreStart, { fieldFormats, logger }: IndexPatternsServiceStartDeps):
Returns:
`{
- indexPatternsServiceFactory: (savedObjectsClient: SavedObjectsClientContract) => Promise;
+ indexPatternsServiceFactory: (savedObjectsClient: SavedObjectsClientContract, elasticsearchClient: ElasticsearchClient) => Promise;
}`
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 653adda6f2ac8..4b4e861aef784 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
@@ -28,6 +28,7 @@
| Function | Description |
| --- | --- |
+| [getCapabilitiesForRollupIndices(indices)](./kibana-plugin-plugins-data-server.getcapabilitiesforrollupindices.md) | |
| [getDefaultSearchParams(uiSettingsClient)](./kibana-plugin-plugins-data-server.getdefaultsearchparams.md) | |
| [getShardTimeout(config)](./kibana-plugin-plugins-data-server.getshardtimeout.md) | |
| [getTime(indexPattern, timeRange, options)](./kibana-plugin-plugins-data-server.gettime.md) | |
@@ -76,6 +77,7 @@
| [esQuery](./kibana-plugin-plugins-data-server.esquery.md) | |
| [fieldFormats](./kibana-plugin-plugins-data-server.fieldformats.md) | |
| [indexPatterns](./kibana-plugin-plugins-data-server.indexpatterns.md) | |
+| [mergeCapabilitiesWithFields](./kibana-plugin-plugins-data-server.mergecapabilitieswithfields.md) | |
| [search](./kibana-plugin-plugins-data-server.search.md) | |
| [UI\_SETTINGS](./kibana-plugin-plugins-data-server.ui_settings.md) | |
diff --git a/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.mergecapabilitieswithfields.md b/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.mergecapabilitieswithfields.md
new file mode 100644
index 0000000000000..2880e2d0d8f2c
--- /dev/null
+++ b/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.mergecapabilitieswithfields.md
@@ -0,0 +1,15 @@
+
+
+[Home](./index.md) > [kibana-plugin-plugins-data-server](./kibana-plugin-plugins-data-server.md) > [mergeCapabilitiesWithFields](./kibana-plugin-plugins-data-server.mergecapabilitieswithfields.md)
+
+## mergeCapabilitiesWithFields variable
+
+Signature:
+
+```typescript
+mergeCapabilitiesWithFields: (rollupIndexCapabilities: {
+ [key: string]: any;
+}, fieldsFromFieldCapsApi: {
+ [key: string]: any;
+}, previousFields?: FieldDescriptor[]) => FieldDescriptor[]
+```
diff --git a/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.plugin.start.md b/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.plugin.start.md
index 660644ae73255..8546ec51a1536 100644
--- a/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.plugin.start.md
+++ b/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.plugin.start.md
@@ -12,7 +12,7 @@ start(core: CoreStart): {
fieldFormatServiceFactory: (uiSettings: import("../../../core/server").IUiSettingsClient) => Promise;
};
indexPatterns: {
- indexPatternsServiceFactory: (savedObjectsClient: Pick) => Promise;
+ indexPatternsServiceFactory: (savedObjectsClient: Pick, elasticsearchClient: import("../../../core/server").ElasticsearchClient) => Promise;
};
search: ISearchStart>;
};
@@ -31,7 +31,7 @@ start(core: CoreStart): {
fieldFormatServiceFactory: (uiSettings: import("../../../core/server").IUiSettingsClient) => Promise;
};
indexPatterns: {
- indexPatternsServiceFactory: (savedObjectsClient: Pick) => Promise;
+ indexPatternsServiceFactory: (savedObjectsClient: Pick, elasticsearchClient: import("../../../core/server").ElasticsearchClient) => Promise;
};
search: ISearchStart>;
}`
diff --git a/src/plugins/data/common/index_patterns/index_patterns/index_patterns.ts b/src/plugins/data/common/index_patterns/index_patterns/index_patterns.ts
index aae9b89cdc61f..284a6b4b696ae 100644
--- a/src/plugins/data/common/index_patterns/index_patterns/index_patterns.ts
+++ b/src/plugins/data/common/index_patterns/index_patterns/index_patterns.ts
@@ -215,13 +215,13 @@ export class IndexPatternsService {
* Get field list by providing { pattern }
* @param options
*/
- getFieldsForWildcard = async (options: GetFieldsOptions = {}) => {
+ getFieldsForWildcard = async (options: GetFieldsOptions) => {
const metaFields = await this.config.get(UI_SETTINGS.META_FIELDS);
return this.apiClient.getFieldsForWildcard({
pattern: options.pattern,
metaFields,
type: options.type,
- params: options.params || {},
+ rollupIndex: options.rollupIndex,
});
};
@@ -231,13 +231,13 @@ export class IndexPatternsService {
*/
getFieldsForIndexPattern = async (
indexPattern: IndexPattern | IndexPatternSpec,
- options: GetFieldsOptions = {}
+ options?: GetFieldsOptions
) =>
this.getFieldsForWildcard({
- pattern: indexPattern.title as string,
- ...options,
type: indexPattern.type,
- params: indexPattern.typeMeta && indexPattern.typeMeta.params,
+ rollupIndex: indexPattern?.typeMeta?.params?.rollup_index,
+ ...options,
+ pattern: indexPattern.title as string,
});
/**
@@ -374,10 +374,10 @@ export class IndexPatternsService {
try {
spec.fields = isFieldRefreshRequired
? await this.refreshFieldSpecMap(spec.fields || {}, id, spec.title as string, {
- pattern: title,
+ pattern: title as string,
metaFields: await this.config.get(UI_SETTINGS.META_FIELDS),
type,
- params: typeMeta && typeMeta.params,
+ rollupIndex: typeMeta?.params?.rollupIndex,
})
: spec.fields;
} catch (err) {
diff --git a/src/plugins/data/common/index_patterns/types.ts b/src/plugins/data/common/index_patterns/types.ts
index 3387bc3b3c19e..b381cc0963333 100644
--- a/src/plugins/data/common/index_patterns/types.ts
+++ b/src/plugins/data/common/index_patterns/types.ts
@@ -86,15 +86,22 @@ export interface SavedObjectsClientCommon {
}
export interface GetFieldsOptions {
- pattern?: string;
+ pattern: string;
type?: string;
- params?: any;
lookBack?: boolean;
metaFields?: string[];
+ rollupIndex?: string;
+}
+
+export interface GetFieldsOptionsTimePattern {
+ pattern: string;
+ metaFields: string[];
+ lookBack: number;
+ interval: string;
}
export interface IIndexPatternsApiClient {
- getFieldsForTimePattern: (options: GetFieldsOptions) => Promise;
+ getFieldsForTimePattern: (options: GetFieldsOptionsTimePattern) => Promise;
getFieldsForWildcard: (options: GetFieldsOptions) => Promise;
}
diff --git a/src/plugins/data/public/index_patterns/index_patterns/index_patterns_api_client.test.ts b/src/plugins/data/public/index_patterns/index_patterns/index_patterns_api_client.test.ts
index 37ee80c2c29e4..8c48ee44fba9c 100644
--- a/src/plugins/data/public/index_patterns/index_patterns/index_patterns_api_client.test.ts
+++ b/src/plugins/data/public/index_patterns/index_patterns/index_patterns_api_client.test.ts
@@ -32,7 +32,12 @@ describe('IndexPatternsApiClient', () => {
test('uses the right URI to fetch fields for time patterns', async function () {
const expectedPath = '/api/index_patterns/_fields_for_time_pattern';
- await indexPatternsApiClient.getFieldsForTimePattern();
+ await indexPatternsApiClient.getFieldsForTimePattern({
+ pattern: 'blah',
+ metaFields: [],
+ lookBack: 5,
+ interval: '',
+ });
expect(fetchSpy).toHaveBeenCalledWith(expectedPath, expect.any(Object));
});
@@ -40,15 +45,7 @@ describe('IndexPatternsApiClient', () => {
test('uses the right URI to fetch fields for wildcard', async function () {
const expectedPath = '/api/index_patterns/_fields_for_wildcard';
- await indexPatternsApiClient.getFieldsForWildcard();
-
- expect(fetchSpy).toHaveBeenCalledWith(expectedPath, expect.any(Object));
- });
-
- test('uses the right URI to fetch fields for wildcard given a type', async function () {
- const expectedPath = '/api/index_patterns/rollup/_fields_for_wildcard';
-
- await indexPatternsApiClient.getFieldsForWildcard({ type: 'rollup' });
+ await indexPatternsApiClient.getFieldsForWildcard({ pattern: 'blah' });
expect(fetchSpy).toHaveBeenCalledWith(expectedPath, expect.any(Object));
});
diff --git a/src/plugins/data/public/index_patterns/index_patterns/index_patterns_api_client.ts b/src/plugins/data/public/index_patterns/index_patterns/index_patterns_api_client.ts
index 377a3f7f91a50..ca0f35d6612b2 100644
--- a/src/plugins/data/public/index_patterns/index_patterns/index_patterns_api_client.ts
+++ b/src/plugins/data/public/index_patterns/index_patterns/index_patterns_api_client.ts
@@ -19,7 +19,11 @@
import { HttpSetup } from 'src/core/public';
import { IndexPatternMissingIndices } from '../../../common/index_patterns/lib';
-import { GetFieldsOptions, IIndexPatternsApiClient } from '../../../common/index_patterns/types';
+import {
+ GetFieldsOptions,
+ IIndexPatternsApiClient,
+ GetFieldsOptionsTimePattern,
+} from '../../../common/index_patterns/types';
const API_BASE_URL: string = `/api/index_patterns/`;
@@ -48,7 +52,7 @@ export class IndexPatternsApiClient implements IIndexPatternsApiClient {
return API_BASE_URL + path.filter(Boolean).map(encodeURIComponent).join('/');
}
- getFieldsForTimePattern(options: GetFieldsOptions = {}) {
+ getFieldsForTimePattern(options: GetFieldsOptionsTimePattern) {
const { pattern, lookBack, metaFields } = options;
const url = this._getUrl(['_fields_for_time_pattern']);
@@ -60,27 +64,12 @@ export class IndexPatternsApiClient implements IIndexPatternsApiClient {
}).then((resp: any) => resp.fields);
}
- getFieldsForWildcard(options: GetFieldsOptions = {}) {
- const { pattern, metaFields, type, params } = options;
-
- let url;
- let query;
-
- if (type) {
- url = this._getUrl([type, '_fields_for_wildcard']);
- query = {
- pattern,
- meta_fields: metaFields,
- params: JSON.stringify(params),
- };
- } else {
- url = this._getUrl(['_fields_for_wildcard']);
- query = {
- pattern,
- meta_fields: metaFields,
- };
- }
-
- return this._request(url, query).then((resp: any) => resp.fields);
+ getFieldsForWildcard({ pattern, metaFields, type, rollupIndex }: GetFieldsOptions) {
+ return this._request(this._getUrl(['_fields_for_wildcard']), {
+ pattern,
+ meta_fields: metaFields,
+ type,
+ rollup_index: rollupIndex,
+ }).then((resp: any) => resp.fields);
}
}
diff --git a/src/plugins/data/public/public.api.md b/src/plugins/data/public/public.api.md
index ac8c9bec30d17..f911378ce97b2 100644
--- a/src/plugins/data/public/public.api.md
+++ b/src/plugins/data/public/public.api.md
@@ -1339,9 +1339,9 @@ export class IndexPatternsService {
// (undocumented)
getCache: () => Promise[] | null | undefined>;
getDefault: () => Promise;
- getFieldsForIndexPattern: (indexPattern: IndexPattern | IndexPatternSpec, options?: GetFieldsOptions) => Promise;
+ getFieldsForIndexPattern: (indexPattern: IndexPattern | IndexPatternSpec, options?: GetFieldsOptions | undefined) => Promise;
// Warning: (ae-forgotten-export) The symbol "GetFieldsOptions" needs to be exported by the entry point index.d.ts
- getFieldsForWildcard: (options?: GetFieldsOptions) => Promise;
+ getFieldsForWildcard: (options: GetFieldsOptions) => Promise;
getIds: (refresh?: boolean) => Promise;
getIdsWithTitle: (refresh?: boolean) => Promise {
- const { pattern, metaFields, fieldCapsOptions } = options;
- return await getFieldCapabilities(this.elasticsearchClient, pattern, metaFields, {
- allow_no_indices: fieldCapsOptions ? fieldCapsOptions.allow_no_indices : this.allowNoIndices,
- });
+ const { pattern, metaFields, fieldCapsOptions, type, rollupIndex } = options;
+ const fieldCapsResponse = await getFieldCapabilities(
+ this.elasticsearchClient,
+ pattern,
+ metaFields,
+ {
+ allow_no_indices: fieldCapsOptions
+ ? fieldCapsOptions.allow_no_indices
+ : this.allowNoIndices,
+ }
+ );
+ if (type === 'rollup' && rollupIndex) {
+ const rollupFields: FieldDescriptor[] = [];
+ const rollupIndexCapabilities = getCapabilitiesForRollupIndices(
+ (
+ await this.elasticsearchClient.rollup.getRollupIndexCaps({
+ index: rollupIndex,
+ })
+ ).body
+ )[rollupIndex].aggs;
+ const fieldCapsResponseObj = keyBy(fieldCapsResponse, 'name');
+
+ // Keep meta fields
+ metaFields!.forEach(
+ (field: string) =>
+ fieldCapsResponseObj[field] && rollupFields.push(fieldCapsResponseObj[field])
+ );
+
+ return mergeCapabilitiesWithFields(
+ rollupIndexCapabilities,
+ fieldCapsResponseObj,
+ rollupFields
+ );
+ }
+ return fieldCapsResponse;
}
/**
diff --git a/src/plugins/data/server/index_patterns/fetcher/lib/__tests__/fixtures/index.js b/src/plugins/data/server/index_patterns/fetcher/lib/__tests__/fixtures/index.js
new file mode 100644
index 0000000000000..d675702ae54e9
--- /dev/null
+++ b/src/plugins/data/server/index_patterns/fetcher/lib/__tests__/fixtures/index.js
@@ -0,0 +1,20 @@
+/*
+ * 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.
+ */
+
+export { jobs } from './jobs';
diff --git a/x-pack/plugins/rollup/server/lib/__tests__/fixtures/jobs.js b/src/plugins/data/server/index_patterns/fetcher/lib/__tests__/fixtures/jobs.js
similarity index 65%
rename from x-pack/plugins/rollup/server/lib/__tests__/fixtures/jobs.js
rename to src/plugins/data/server/index_patterns/fetcher/lib/__tests__/fixtures/jobs.js
index c03b7c33abe0a..39ebd9595eeaf 100644
--- a/x-pack/plugins/rollup/server/lib/__tests__/fixtures/jobs.js
+++ b/src/plugins/data/server/index_patterns/fetcher/lib/__tests__/fixtures/jobs.js
@@ -1,7 +1,20 @@
/*
- * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
- * or more contributor license agreements. Licensed under the Elastic License;
- * you may not use this file except in compliance with the Elastic License.
+ * 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.
*/
export const jobs = [
diff --git a/x-pack/plugins/rollup/server/lib/__tests__/jobs_compatibility.js b/src/plugins/data/server/index_patterns/fetcher/lib/__tests__/jobs_compatibility.js
similarity index 81%
rename from x-pack/plugins/rollup/server/lib/__tests__/jobs_compatibility.js
rename to src/plugins/data/server/index_patterns/fetcher/lib/__tests__/jobs_compatibility.js
index a67f67de859f5..e3c93ac1f8616 100644
--- a/x-pack/plugins/rollup/server/lib/__tests__/jobs_compatibility.js
+++ b/src/plugins/data/server/index_patterns/fetcher/lib/__tests__/jobs_compatibility.js
@@ -1,8 +1,22 @@
/*
- * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
- * or more contributor license agreements. Licensed under the Elastic License;
- * you may not use this file except in compliance with the Elastic License.
+ * 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 expect from '@kbn/expect';
import { areJobsCompatible, mergeJobConfigurations } from '../jobs_compatibility';
import { jobs } from './fixtures';
diff --git a/src/plugins/data/server/index_patterns/fetcher/lib/index.ts b/src/plugins/data/server/index_patterns/fetcher/lib/index.ts
index 20e74d2b1a579..b2fd3a1a09a25 100644
--- a/src/plugins/data/server/index_patterns/fetcher/lib/index.ts
+++ b/src/plugins/data/server/index_patterns/fetcher/lib/index.ts
@@ -20,3 +20,5 @@
export { getFieldCapabilities, shouldReadFieldFromDocValues } from './field_capabilities';
export { resolveTimePattern } from './resolve_time_pattern';
export { createNoMatchingIndicesError } from './errors';
+export * from './merge_capabilities_with_fields';
+export * from './map_capabilities';
diff --git a/x-pack/plugins/rollup/server/lib/jobs_compatibility.ts b/src/plugins/data/server/index_patterns/fetcher/lib/jobs_compatibility.ts
similarity index 79%
rename from x-pack/plugins/rollup/server/lib/jobs_compatibility.ts
rename to src/plugins/data/server/index_patterns/fetcher/lib/jobs_compatibility.ts
index f5f54cf9a54e8..f21de8907ee24 100644
--- a/x-pack/plugins/rollup/server/lib/jobs_compatibility.ts
+++ b/src/plugins/data/server/index_patterns/fetcher/lib/jobs_compatibility.ts
@@ -1,7 +1,20 @@
/*
- * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
- * or more contributor license agreements. Licensed under the Elastic License;
- * you may not use this file except in compliance with the Elastic License.
+ * 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 { isEqual } from 'lodash';
diff --git a/src/plugins/data/server/index_patterns/fetcher/lib/map_capabilities.ts b/src/plugins/data/server/index_patterns/fetcher/lib/map_capabilities.ts
new file mode 100644
index 0000000000000..6187174834012
--- /dev/null
+++ b/src/plugins/data/server/index_patterns/fetcher/lib/map_capabilities.ts
@@ -0,0 +1,37 @@
+/*
+ * 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 { mergeJobConfigurations } from './jobs_compatibility';
+
+export function getCapabilitiesForRollupIndices(indices: { [key: string]: any }) {
+ const indexNames = Object.keys(indices);
+ const capabilities = {} as { [key: string]: any };
+
+ indexNames.forEach((index) => {
+ try {
+ capabilities[index] = mergeJobConfigurations(indices[index].rollup_jobs);
+ } catch (e) {
+ capabilities[index] = {
+ error: e.message,
+ };
+ }
+ });
+
+ return capabilities;
+}
diff --git a/x-pack/plugins/rollup/server/lib/merge_capabilities_with_fields.ts b/src/plugins/data/server/index_patterns/fetcher/lib/merge_capabilities_with_fields.ts
similarity index 70%
rename from x-pack/plugins/rollup/server/lib/merge_capabilities_with_fields.ts
rename to src/plugins/data/server/index_patterns/fetcher/lib/merge_capabilities_with_fields.ts
index 51111e9e45d0a..dd69f4b7ff007 100644
--- a/x-pack/plugins/rollup/server/lib/merge_capabilities_with_fields.ts
+++ b/src/plugins/data/server/index_patterns/fetcher/lib/merge_capabilities_with_fields.ts
@@ -1,20 +1,30 @@
/*
- * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
- * or more contributor license agreements. Licensed under the Elastic License;
- * you may not use this file except in compliance with the Elastic License.
+ * 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.
*/
// Merge rollup capabilities information with field information
-export interface Field {
- name?: string;
- [key: string]: any;
-}
+import { FieldDescriptor } from '../index_patterns_fetcher';
export const mergeCapabilitiesWithFields = (
rollupIndexCapabilities: { [key: string]: any },
fieldsFromFieldCapsApi: { [key: string]: any },
- previousFields: Field[] = []
+ previousFields: FieldDescriptor[] = []
) => {
const rollupFields = [...previousFields];
const rollupFieldNames: string[] = [];
diff --git a/src/plugins/data/server/index_patterns/index.ts b/src/plugins/data/server/index_patterns/index.ts
index 683d1c445fd72..3305b1bb9a92f 100644
--- a/src/plugins/data/server/index_patterns/index.ts
+++ b/src/plugins/data/server/index_patterns/index.ts
@@ -17,5 +17,11 @@
* under the License.
*/
export * from './utils';
-export { IndexPatternsFetcher, FieldDescriptor, shouldReadFieldFromDocValues } from './fetcher';
+export {
+ IndexPatternsFetcher,
+ FieldDescriptor,
+ shouldReadFieldFromDocValues,
+ mergeCapabilitiesWithFields,
+ getCapabilitiesForRollupIndices,
+} from './fetcher';
export { IndexPatternsService, IndexPatternsServiceStart } from './index_patterns_service';
diff --git a/src/plugins/data/server/index_patterns/index_patterns_api_client.ts b/src/plugins/data/server/index_patterns/index_patterns_api_client.ts
index 2dc6f40c5a6f1..21a3bf6e73e61 100644
--- a/src/plugins/data/server/index_patterns/index_patterns_api_client.ts
+++ b/src/plugins/data/server/index_patterns/index_patterns_api_client.ts
@@ -17,13 +17,30 @@
* under the License.
*/
-import { GetFieldsOptions, IIndexPatternsApiClient } from '../../common/index_patterns/types';
+import { ElasticsearchClient } from 'kibana/server';
+import {
+ GetFieldsOptions,
+ IIndexPatternsApiClient,
+ GetFieldsOptionsTimePattern,
+} from '../../common/index_patterns/types';
+import { IndexPatternsFetcher } from './fetcher';
export class IndexPatternsApiServer implements IIndexPatternsApiClient {
- async getFieldsForTimePattern(options: GetFieldsOptions = {}) {
- throw new Error('IndexPatternsApiServer - getFieldsForTimePattern not defined');
+ esClient: ElasticsearchClient;
+ constructor(elasticsearchClient: ElasticsearchClient) {
+ this.esClient = elasticsearchClient;
}
- async getFieldsForWildcard(options: GetFieldsOptions = {}) {
- throw new Error('IndexPatternsApiServer - getFieldsForWildcard not defined');
+ async getFieldsForWildcard({ pattern, metaFields, type, rollupIndex }: GetFieldsOptions) {
+ const indexPatterns = new IndexPatternsFetcher(this.esClient);
+ return await indexPatterns.getFieldsForWildcard({
+ pattern,
+ metaFields,
+ type,
+ rollupIndex,
+ });
+ }
+ async getFieldsForTimePattern(options: GetFieldsOptionsTimePattern) {
+ const indexPatterns = new IndexPatternsFetcher(this.esClient);
+ return await indexPatterns.getFieldsForTimePattern(options);
}
}
diff --git a/src/plugins/data/server/index_patterns/index_patterns_service.ts b/src/plugins/data/server/index_patterns/index_patterns_service.ts
index d665e3715fa72..af2d4d6a73e0f 100644
--- a/src/plugins/data/server/index_patterns/index_patterns_service.ts
+++ b/src/plugins/data/server/index_patterns/index_patterns_service.ts
@@ -17,7 +17,14 @@
* under the License.
*/
-import { CoreSetup, CoreStart, Plugin, Logger, SavedObjectsClientContract } from 'kibana/server';
+import {
+ CoreSetup,
+ CoreStart,
+ Plugin,
+ Logger,
+ SavedObjectsClientContract,
+ ElasticsearchClient,
+} from 'kibana/server';
import { registerRoutes } from './routes';
import { indexPatternSavedObjectType } from '../saved_objects';
import { capabilitiesProvider } from './capabilities_provider';
@@ -29,7 +36,8 @@ import { SavedObjectsClientServerToCommon } from './saved_objects_client_wrapper
export interface IndexPatternsServiceStart {
indexPatternsServiceFactory: (
- savedObjectsClient: SavedObjectsClientContract
+ savedObjectsClient: SavedObjectsClientContract,
+ elasticsearchClient: ElasticsearchClient
) => Promise;
}
@@ -50,14 +58,17 @@ export class IndexPatternsService implements Plugin {
+ indexPatternsServiceFactory: async (
+ savedObjectsClient: SavedObjectsClientContract,
+ elasticsearchClient: ElasticsearchClient
+ ) => {
const uiSettingsClient = uiSettings.asScopedToClient(savedObjectsClient);
const formats = await fieldFormats.fieldFormatServiceFactory(uiSettingsClient);
return new IndexPatternsCommonService({
uiSettings: new UiSettingsServerToCommon(uiSettingsClient),
savedObjectsClient: new SavedObjectsClientServerToCommon(savedObjectsClient),
- apiClient: new IndexPatternsApiServer(),
+ apiClient: new IndexPatternsApiServer(elasticsearchClient),
fieldFormats: formats,
onError: (error) => {
logger.error(error);
diff --git a/src/plugins/data/server/index_patterns/routes.ts b/src/plugins/data/server/index_patterns/routes.ts
index 041eb235d01e0..f8af52954fc61 100644
--- a/src/plugins/data/server/index_patterns/routes.ts
+++ b/src/plugins/data/server/index_patterns/routes.ts
@@ -42,13 +42,15 @@ export function registerRoutes(http: HttpServiceSetup) {
meta_fields: schema.oneOf([schema.string(), schema.arrayOf(schema.string())], {
defaultValue: [],
}),
+ type: schema.maybe(schema.string()),
+ rollup_index: schema.maybe(schema.string()),
}),
},
},
async (context, request, response) => {
const { asCurrentUser } = context.core.elasticsearch.client;
const indexPatterns = new IndexPatternsFetcher(asCurrentUser);
- const { pattern, meta_fields: metaFields } = request.query;
+ const { pattern, meta_fields: metaFields, type, rollup_index: rollupIndex } = request.query;
let parsedFields: string[] = [];
try {
@@ -61,6 +63,8 @@ export function registerRoutes(http: HttpServiceSetup) {
const fields = await indexPatterns.getFieldsForWildcard({
pattern,
metaFields: parsedFields,
+ type,
+ rollupIndex,
});
return response.ok({
diff --git a/src/plugins/data/server/search/aggs/aggs_service.test.ts b/src/plugins/data/server/search/aggs/aggs_service.test.ts
index cb4239cc339c4..e58420f6c2f07 100644
--- a/src/plugins/data/server/search/aggs/aggs_service.test.ts
+++ b/src/plugins/data/server/search/aggs/aggs_service.test.ts
@@ -17,7 +17,7 @@
* under the License.
*/
-import { KibanaRequest } from 'src/core/server';
+import { KibanaRequest, ElasticsearchClient } from 'src/core/server';
import { coreMock } from '../../../../../core/server/mocks';
import { expressionsPluginMock } from '../../../../../plugins/expressions/server/mocks';
@@ -63,7 +63,8 @@ describe('AggsService - server', () => {
expect(start).toHaveProperty('asScopedToClient');
const contract = await start.asScopedToClient(
- savedObjects.getScopedClient({} as KibanaRequest)
+ savedObjects.getScopedClient({} as KibanaRequest),
+ {} as ElasticsearchClient
);
expect(contract).toHaveProperty('calculateAutoTimeExpression');
expect(contract).toHaveProperty('createAggConfigs');
@@ -74,7 +75,10 @@ describe('AggsService - server', () => {
service.setup(setupDeps);
const start = await service
.start(startDeps)
- .asScopedToClient(savedObjects.getScopedClient({} as KibanaRequest));
+ .asScopedToClient(
+ savedObjects.getScopedClient({} as KibanaRequest),
+ {} as ElasticsearchClient
+ );
expect(start.types.get('terms').name).toBe('terms');
});
@@ -83,7 +87,10 @@ describe('AggsService - server', () => {
service.setup(setupDeps);
const start = await service
.start(startDeps)
- .asScopedToClient(savedObjects.getScopedClient({} as KibanaRequest));
+ .asScopedToClient(
+ savedObjects.getScopedClient({} as KibanaRequest),
+ {} as ElasticsearchClient
+ );
const aggTypes = getAggTypes();
expect(start.types.getAll().buckets.length).toBe(aggTypes.buckets.length);
@@ -103,7 +110,10 @@ describe('AggsService - server', () => {
const start = await service
.start(startDeps)
- .asScopedToClient(savedObjects.getScopedClient({} as KibanaRequest));
+ .asScopedToClient(
+ savedObjects.getScopedClient({} as KibanaRequest),
+ {} as ElasticsearchClient
+ );
const aggTypes = getAggTypes();
expect(start.types.getAll().buckets.length).toBe(aggTypes.buckets.length + 1);
diff --git a/src/plugins/data/server/search/aggs/aggs_service.ts b/src/plugins/data/server/search/aggs/aggs_service.ts
index c805c8af6694c..c23f748b1eeb5 100644
--- a/src/plugins/data/server/search/aggs/aggs_service.ts
+++ b/src/plugins/data/server/search/aggs/aggs_service.ts
@@ -19,7 +19,11 @@
import { pick } from 'lodash';
-import { UiSettingsServiceStart, SavedObjectsClientContract } from 'src/core/server';
+import {
+ UiSettingsServiceStart,
+ SavedObjectsClientContract,
+ ElasticsearchClient,
+} from 'src/core/server';
import { ExpressionsServiceSetup } from 'src/plugins/expressions/common';
import {
AggsCommonService,
@@ -65,7 +69,10 @@ export class AggsService {
public start({ fieldFormats, uiSettings, indexPatterns }: AggsStartDependencies): AggsStart {
return {
- asScopedToClient: async (savedObjectsClient: SavedObjectsClientContract) => {
+ asScopedToClient: async (
+ savedObjectsClient: SavedObjectsClientContract,
+ elasticsearchClient: ElasticsearchClient
+ ) => {
const uiSettingsClient = uiSettings.asScopedToClient(savedObjectsClient);
const formats = await fieldFormats.fieldFormatServiceFactory(uiSettingsClient);
@@ -82,8 +89,9 @@ export class AggsService {
types,
} = this.aggsCommonService.start({
getConfig,
- getIndexPattern: (await indexPatterns.indexPatternsServiceFactory(savedObjectsClient))
- .get,
+ getIndexPattern: (
+ await indexPatterns.indexPatternsServiceFactory(savedObjectsClient, elasticsearchClient)
+ ).get,
isDefaultTimezone,
});
diff --git a/src/plugins/data/server/search/aggs/types.ts b/src/plugins/data/server/search/aggs/types.ts
index 1b21d948b25d9..2c28c970cbb84 100644
--- a/src/plugins/data/server/search/aggs/types.ts
+++ b/src/plugins/data/server/search/aggs/types.ts
@@ -17,11 +17,14 @@
* under the License.
*/
-import { SavedObjectsClientContract } from 'src/core/server';
+import { SavedObjectsClientContract, ElasticsearchClient } from 'src/core/server';
import { AggsCommonSetup, AggsStart as Start } from '../../../common';
export type AggsSetup = AggsCommonSetup;
export interface AggsStart {
- asScopedToClient: (savedObjectsClient: SavedObjectsClientContract) => Promise;
+ asScopedToClient: (
+ savedObjectsClient: SavedObjectsClientContract,
+ elasticsearchClient: ElasticsearchClient
+ ) => Promise;
}
diff --git a/src/plugins/data/server/search/search_service.ts b/src/plugins/data/server/search/search_service.ts
index 04ee0e95c7f08..6394c37c993b3 100644
--- a/src/plugins/data/server/search/search_service.ts
+++ b/src/plugins/data/server/search/search_service.ts
@@ -149,7 +149,11 @@ export class SearchService implements Plugin {
{ fieldFormats, indexPatterns }: SearchServiceStartDependencies
): ISearchStart {
return {
- aggs: this.aggsService.start({ fieldFormats, uiSettings, indexPatterns }),
+ aggs: this.aggsService.start({
+ fieldFormats,
+ uiSettings,
+ indexPatterns,
+ }),
getSearchStrategy: this.getSearchStrategy,
search: this.search.bind(this),
searchSource: {
@@ -157,7 +161,8 @@ export class SearchService implements Plugin {
const esClient = elasticsearch.client.asScoped(request);
const savedObjectsClient = savedObjects.getScopedClient(request);
const scopedIndexPatterns = await indexPatterns.indexPatternsServiceFactory(
- savedObjectsClient
+ savedObjectsClient,
+ esClient.asCurrentUser
);
const uiSettingsClient = uiSettings.asScopedToClient(savedObjectsClient);
diff --git a/src/plugins/data/server/server.api.md b/src/plugins/data/server/server.api.md
index fba86098a76fa..06c8a053e5ad2 100644
--- a/src/plugins/data/server/server.api.md
+++ b/src/plugins/data/server/server.api.md
@@ -15,7 +15,8 @@ import { CoreStart } from 'src/core/server';
import { CoreStart as CoreStart_2 } from 'kibana/server';
import { DatatableColumn } from 'src/plugins/expressions';
import { Duration } from 'moment';
-import { ElasticsearchClient } from 'kibana/server';
+import { ElasticsearchClient } from 'src/core/server';
+import { ElasticsearchClient as ElasticsearchClient_2 } from 'kibana/server';
import { Ensure } from '@kbn/utility-types';
import { EnvironmentMode } from '@kbn/config';
import { ErrorToastOptions } from 'src/core/public/notifications';
@@ -360,6 +361,15 @@ export type Filter = {
query?: any;
};
+// Warning: (ae-missing-release-tag) "getCapabilitiesForRollupIndices" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
+//
+// @public (undocumented)
+export function getCapabilitiesForRollupIndices(indices: {
+ [key: string]: any;
+}): {
+ [key: string]: any;
+};
+
// Warning: (ae-forgotten-export) The symbol "IUiSettingsClient" needs to be exported by the entry point index.d.ts
// Warning: (ae-missing-release-tag) "getDefaultSearchParams" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
@@ -659,7 +669,7 @@ export const indexPatterns: {
//
// @public (undocumented)
export class IndexPatternsFetcher {
- constructor(elasticsearchClient: ElasticsearchClient, allowNoIndices?: boolean);
+ constructor(elasticsearchClient: ElasticsearchClient_2, allowNoIndices?: boolean);
getFieldsForTimePattern(options: {
pattern: string;
metaFields: string[];
@@ -672,6 +682,8 @@ export class IndexPatternsFetcher {
fieldCapsOptions?: {
allow_no_indices: boolean;
};
+ type?: string;
+ rollupIndex?: string;
}): Promise;
}
@@ -686,7 +698,7 @@ export class IndexPatternsService implements Plugin_3 Promise;
+ indexPatternsServiceFactory: (savedObjectsClient: SavedObjectsClientContract_2, elasticsearchClient: ElasticsearchClient_2) => Promise;
};
}
@@ -788,6 +800,15 @@ export interface KueryNode {
type: keyof NodeTypes;
}
+// Warning: (ae-missing-release-tag) "mergeCapabilitiesWithFields" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
+//
+// @public (undocumented)
+export const mergeCapabilitiesWithFields: (rollupIndexCapabilities: {
+ [key: string]: any;
+}, fieldsFromFieldCapsApi: {
+ [key: string]: any;
+}, previousFields?: FieldDescriptor[]) => FieldDescriptor[];
+
// Warning: (ae-missing-release-tag) "METRIC_TYPES" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
@@ -891,7 +912,7 @@ export class Plugin implements Plugin_2 Promise;
};
indexPatterns: {
- indexPatternsServiceFactory: (savedObjectsClient: Pick) => Promise;
+ indexPatternsServiceFactory: (savedObjectsClient: Pick, elasticsearchClient: import("../../../core/server").ElasticsearchClient) => Promise;
};
search: ISearchStart>;
};
@@ -1147,22 +1168,22 @@ export function usageProvider(core: CoreSetup_2): SearchUsage;
// src/plugins/data/server/index.ts:101:26 - (ae-forgotten-export) The symbol "TruncateFormat" needs to be exported by the entry point index.d.ts
// src/plugins/data/server/index.ts:127:27 - (ae-forgotten-export) The symbol "isFilterable" needs to be exported by the entry point index.d.ts
// src/plugins/data/server/index.ts:127:27 - (ae-forgotten-export) The symbol "isNestedField" needs to be exported by the entry point index.d.ts
-// src/plugins/data/server/index.ts:234:20 - (ae-forgotten-export) The symbol "getRequestInspectorStats" needs to be exported by the entry point index.d.ts
-// src/plugins/data/server/index.ts:234:20 - (ae-forgotten-export) The symbol "getResponseInspectorStats" needs to be exported by the entry point index.d.ts
-// src/plugins/data/server/index.ts:234:20 - (ae-forgotten-export) The symbol "tabifyAggResponse" needs to be exported by the entry point index.d.ts
-// src/plugins/data/server/index.ts:234:20 - (ae-forgotten-export) The symbol "tabifyGetColumns" needs to be exported by the entry point index.d.ts
-// src/plugins/data/server/index.ts:249:5 - (ae-forgotten-export) The symbol "getTotalLoaded" needs to be exported by the entry point index.d.ts
-// src/plugins/data/server/index.ts:250:5 - (ae-forgotten-export) The symbol "toSnakeCase" 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_patterns/index_patterns_service.ts:50:14 - (ae-forgotten-export) The symbol "IndexPatternsService" needs to be exported by the entry point index.d.ts
+// src/plugins/data/server/index.ts:236:20 - (ae-forgotten-export) The symbol "getRequestInspectorStats" needs to be exported by the entry point index.d.ts
+// src/plugins/data/server/index.ts:236:20 - (ae-forgotten-export) The symbol "getResponseInspectorStats" needs to be exported by the entry point index.d.ts
+// src/plugins/data/server/index.ts:236:20 - (ae-forgotten-export) The symbol "tabifyAggResponse" needs to be exported by the entry point index.d.ts
+// src/plugins/data/server/index.ts:236:20 - (ae-forgotten-export) The symbol "tabifyGetColumns" needs to be exported by the entry point index.d.ts
+// src/plugins/data/server/index.ts:251:5 - (ae-forgotten-export) The symbol "getTotalLoaded" needs to be exported by the entry point index.d.ts
+// src/plugins/data/server/index.ts:252:5 - (ae-forgotten-export) The symbol "toSnakeCase" needs to be exported by the entry point index.d.ts
+// src/plugins/data/server/index.ts:256:1 - (ae-forgotten-export) The symbol "CidrMask" needs to be exported by the entry point index.d.ts
+// src/plugins/data/server/index.ts:257:1 - (ae-forgotten-export) The symbol "dateHistogramInterval" needs to be exported by the entry point index.d.ts
+// src/plugins/data/server/index.ts:266:1 - (ae-forgotten-export) The symbol "InvalidEsCalendarIntervalError" needs to be exported by the entry point index.d.ts
+// src/plugins/data/server/index.ts:267:1 - (ae-forgotten-export) The symbol "InvalidEsIntervalFormatError" needs to be exported by the entry point index.d.ts
+// src/plugins/data/server/index.ts:268:1 - (ae-forgotten-export) The symbol "Ipv4Address" needs to be exported by the entry point index.d.ts
+// src/plugins/data/server/index.ts:272:1 - (ae-forgotten-export) The symbol "isValidEsInterval" needs to be exported by the entry point index.d.ts
+// src/plugins/data/server/index.ts:273:1 - (ae-forgotten-export) The symbol "isValidInterval" needs to be exported by the entry point index.d.ts
+// src/plugins/data/server/index.ts:277:1 - (ae-forgotten-export) The symbol "propFilter" needs to be exported by the entry point index.d.ts
+// src/plugins/data/server/index.ts:280:1 - (ae-forgotten-export) The symbol "toAbsoluteDates" needs to be exported by the entry point index.d.ts
+// src/plugins/data/server/index_patterns/index_patterns_service.ts:58:14 - (ae-forgotten-export) The symbol "IndexPatternsService" needs to be exported by the entry point index.d.ts
// src/plugins/data/server/plugin.ts:88:66 - (ae-forgotten-export) The symbol "DataEnhancements" needs to be exported by the entry point index.d.ts
// src/plugins/data/server/search/types.ts:91:5 - (ae-forgotten-export) The symbol "ISearchStartSearchSource" needs to be exported by the entry point index.d.ts
diff --git a/src/plugins/vis_type_timeseries/server/lib/get_fields.ts b/src/plugins/vis_type_timeseries/server/lib/get_fields.ts
index b52188129f77f..dc49e280a2bb7 100644
--- a/src/plugins/vis_type_timeseries/server/lib/get_fields.ts
+++ b/src/plugins/vis_type_timeseries/server/lib/get_fields.ts
@@ -62,10 +62,12 @@ export async function getFields(
let indexPatternString = indexPattern;
if (!indexPatternString) {
- const [{ savedObjects }, { data }] = await framework.core.getStartServices();
+ const [{ savedObjects, elasticsearch }, { data }] = await framework.core.getStartServices();
const savedObjectsClient = savedObjects.getScopedClient(request);
+ const clusterClient = elasticsearch.client.asScoped(request).asCurrentUser;
const indexPatternsService = await data.indexPatterns.indexPatternsServiceFactory(
- savedObjectsClient
+ savedObjectsClient,
+ clusterClient
);
const defaultIndexPattern = await indexPatternsService.getDefault();
indexPatternString = get(defaultIndexPattern, 'title', '');
diff --git a/test/functional/page_objects/settings_page.ts b/test/functional/page_objects/settings_page.ts
index e29f75b806574..ca3e26be5d74b 100644
--- a/test/functional/page_objects/settings_page.ts
+++ b/test/functional/page_objects/settings_page.ts
@@ -350,6 +350,7 @@ export function SettingsPageProvider({ getService, getPageObjects }: FtrProvider
if (timefield) {
await this.selectTimeFieldOption(timefield);
}
+ await new Promise((r) => setTimeout(r, 5000 * 60));
await (await this.getCreateIndexPatternButton()).click();
});
await PageObjects.header.waitUntilLoadingHasFinished();
diff --git a/test/plugin_functional/plugins/data_search/server/plugin.ts b/test/plugin_functional/plugins/data_search/server/plugin.ts
index e016ef56802f3..ca22e82188403 100644
--- a/test/plugin_functional/plugins/data_search/server/plugin.ts
+++ b/test/plugin_functional/plugins/data_search/server/plugin.ts
@@ -58,14 +58,16 @@ export class DataSearchTestPlugin
},
},
async (context, req, res) => {
- const [{ savedObjects }, { data }] = await core.getStartServices();
+ const [{ savedObjects, elasticsearch }, { data }] = await core.getStartServices();
const service = await data.search.searchSource.asScoped(req);
+ const clusterClient = elasticsearch.client.asScoped(req).asCurrentUser;
const savedObjectsClient = savedObjects.getScopedClient(req);
// Since the index pattern ID can change on each test run, we need
// to look it up on the fly and insert it into the request.
const indexPatterns = await data.indexPatterns.indexPatternsServiceFactory(
- savedObjectsClient
+ savedObjectsClient,
+ clusterClient
);
const ids = await indexPatterns.getIds();
// @ts-expect-error Force overwriting the request
diff --git a/test/plugin_functional/plugins/index_patterns/server/plugin.ts b/test/plugin_functional/plugins/index_patterns/server/plugin.ts
index a54502b740211..7dc5e975c528e 100644
--- a/test/plugin_functional/plugins/index_patterns/server/plugin.ts
+++ b/test/plugin_functional/plugins/index_patterns/server/plugin.ts
@@ -36,12 +36,34 @@ export class IndexPatternsTestPlugin
public setup(core: CoreSetup) {
const router = core.http.createRouter();
+ router.post(
+ {
+ path: '/api/index-patterns-plugin/create',
+ validate: {
+ body: schema.object({}, { unknowns: 'allow' }),
+ },
+ },
+ async (context, req, res) => {
+ const [{ savedObjects, elasticsearch }, { data }] = await core.getStartServices();
+ const savedObjectsClient = savedObjects.getScopedClient(req);
+ const service = await data.indexPatterns.indexPatternsServiceFactory(
+ savedObjectsClient,
+ elasticsearch.client.asScoped(req).asCurrentUser
+ );
+ const ids = await service.createAndSave(req.body);
+ return res.ok({ body: ids });
+ }
+ );
+
router.get(
{ path: '/api/index-patterns-plugin/get-all', validate: false },
async (context, req, res) => {
- const [{ savedObjects }, { data }] = await core.getStartServices();
+ const [{ savedObjects, elasticsearch }, { data }] = await core.getStartServices();
const savedObjectsClient = savedObjects.getScopedClient(req);
- const service = await data.indexPatterns.indexPatternsServiceFactory(savedObjectsClient);
+ const service = await data.indexPatterns.indexPatternsServiceFactory(
+ savedObjectsClient,
+ elasticsearch.client.asScoped(req).asCurrentUser
+ );
const ids = await service.getIds();
return res.ok({ body: ids });
}
@@ -58,9 +80,12 @@ export class IndexPatternsTestPlugin
},
async (context, req, res) => {
const id = (req.params as Record).id;
- const [{ savedObjects }, { data }] = await core.getStartServices();
+ const [{ savedObjects, elasticsearch }, { data }] = await core.getStartServices();
const savedObjectsClient = savedObjects.getScopedClient(req);
- const service = await data.indexPatterns.indexPatternsServiceFactory(savedObjectsClient);
+ const service = await data.indexPatterns.indexPatternsServiceFactory(
+ savedObjectsClient,
+ elasticsearch.client.asScoped(req).asCurrentUser
+ );
const ip = await service.get(id);
return res.ok({ body: ip.toSpec() });
}
@@ -76,10 +101,13 @@ export class IndexPatternsTestPlugin
},
},
async (context, req, res) => {
- const [{ savedObjects }, { data }] = await core.getStartServices();
+ const [{ savedObjects, elasticsearch }, { data }] = await core.getStartServices();
const id = (req.params as Record).id;
const savedObjectsClient = savedObjects.getScopedClient(req);
- const service = await data.indexPatterns.indexPatternsServiceFactory(savedObjectsClient);
+ const service = await data.indexPatterns.indexPatternsServiceFactory(
+ savedObjectsClient,
+ elasticsearch.client.asScoped(req).asCurrentUser
+ );
const ip = await service.get(id);
await service.updateSavedObject(ip);
return res.ok();
@@ -96,10 +124,13 @@ export class IndexPatternsTestPlugin
},
},
async (context, req, res) => {
- const [{ savedObjects }, { data }] = await core.getStartServices();
+ const [{ savedObjects, elasticsearch }, { data }] = await core.getStartServices();
const id = (req.params as Record).id;
const savedObjectsClient = savedObjects.getScopedClient(req);
- const service = await data.indexPatterns.indexPatternsServiceFactory(savedObjectsClient);
+ const service = await data.indexPatterns.indexPatternsServiceFactory(
+ savedObjectsClient,
+ elasticsearch.client.asScoped(req).asCurrentUser
+ );
await service.delete(id);
return res.ok();
}
diff --git a/test/plugin_functional/test_suites/data_plugin/index_patterns.ts b/test/plugin_functional/test_suites/data_plugin/index_patterns.ts
index 2c846dc780311..6d8f65fa38777 100644
--- a/test/plugin_functional/test_suites/data_plugin/index_patterns.ts
+++ b/test/plugin_functional/test_suites/data_plugin/index_patterns.ts
@@ -25,13 +25,30 @@ export default function ({ getService }: PluginFunctionalProviderContext) {
// skipping the tests as it deletes index patterns created by other test causing unexpected failures
// https://github.com/elastic/kibana/issues/79886
- describe.skip('index patterns', function () {
+ describe('index patterns', function () {
let indexPatternId = '';
+ it('can create an index pattern', async () => {
+ const title = 'shakes*';
+ const fieldFormats = { bytes: { id: 'bytes' } };
+ const body = await (
+ await supertest
+ .post('/api/index-patterns-plugin/create')
+ .set('kbn-xsrf', 'anything')
+ .send({ title, fieldFormats })
+ .expect(200)
+ ).body;
+
+ indexPatternId = body.id;
+ expect(body.id).not.empty();
+ expect(body.title).to.equal(title);
+ expect(body.fields.length).to.equal(15);
+ expect(body.fieldFormatMap).to.eql(fieldFormats);
+ });
+
it('can get all ids', async () => {
const body = await (await supertest.get('/api/index-patterns-plugin/get-all').expect(200))
.body;
- indexPatternId = body[0];
expect(body.length > 0).to.equal(true);
});
diff --git a/x-pack/plugins/rollup/public/index_pattern_creation/rollup_index_pattern_creation_config.js b/x-pack/plugins/rollup/public/index_pattern_creation/rollup_index_pattern_creation_config.js
index 643cc3efb0136..e021831d2f438 100644
--- a/x-pack/plugins/rollup/public/index_pattern_creation/rollup_index_pattern_creation_config.js
+++ b/x-pack/plugins/rollup/public/index_pattern_creation/rollup_index_pattern_creation_config.js
@@ -161,9 +161,7 @@ export class RollupIndexPatternCreationConfig extends IndexPatternCreationConfig
getFetchForWildcardOptions = () => {
return {
type: this.type,
- params: {
- rollup_index: this.rollupIndex,
- },
+ rollupIndex: this.rollupIndex,
};
};
}
diff --git a/x-pack/plugins/rollup/server/lib/__tests__/fixtures/index.js b/x-pack/plugins/rollup/server/lib/__tests__/fixtures/index.js
deleted file mode 100644
index e97606c1fadfb..0000000000000
--- a/x-pack/plugins/rollup/server/lib/__tests__/fixtures/index.js
+++ /dev/null
@@ -1,7 +0,0 @@
-/*
- * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
- * or more contributor license agreements. Licensed under the Elastic License;
- * you may not use this file except in compliance with the Elastic License.
- */
-
-export { jobs } from './jobs';
diff --git a/x-pack/plugins/rollup/server/lib/map_capabilities.ts b/x-pack/plugins/rollup/server/lib/map_capabilities.ts
deleted file mode 100644
index 233c6d1dd4b4b..0000000000000
--- a/x-pack/plugins/rollup/server/lib/map_capabilities.ts
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
- * or more contributor license agreements. Licensed under the Elastic License;
- * you may not use this file except in compliance with the Elastic License.
- */
-
-import { mergeJobConfigurations } from './jobs_compatibility';
-
-export function getCapabilitiesForRollupIndices(indices: { [key: string]: any }) {
- const indexNames = Object.keys(indices);
- const capabilities = {} as { [key: string]: any };
-
- indexNames.forEach((index) => {
- try {
- capabilities[index] = mergeJobConfigurations(indices[index].rollup_jobs);
- } catch (e) {
- capabilities[index] = {
- error: e.message,
- };
- }
- });
-
- return capabilities;
-}
diff --git a/x-pack/plugins/rollup/server/lib/search_strategies/rollup_search_strategy.ts b/x-pack/plugins/rollup/server/lib/search_strategies/rollup_search_strategy.ts
index f439ac555aed9..dcf6629d35397 100644
--- a/x-pack/plugins/rollup/server/lib/search_strategies/rollup_search_strategy.ts
+++ b/x-pack/plugins/rollup/server/lib/search_strategies/rollup_search_strategy.ts
@@ -6,8 +6,11 @@
import { keyBy, isString } from 'lodash';
import { ILegacyScopedClusterClient } from 'src/core/server';
import { ReqFacade } from '../../../../../../src/plugins/vis_type_timeseries/server';
-import { mergeCapabilitiesWithFields } from '../merge_capabilities_with_fields';
-import { getCapabilitiesForRollupIndices } from '../map_capabilities';
+
+import {
+ mergeCapabilitiesWithFields,
+ getCapabilitiesForRollupIndices,
+} from '../../../../../../src/plugins/data/server';
const getRollupIndices = (rollupData: { [key: string]: any }) => Object.keys(rollupData);
diff --git a/x-pack/plugins/rollup/server/plugin.ts b/x-pack/plugins/rollup/server/plugin.ts
index fe193150fc1ca..51920af7c8cbc 100644
--- a/x-pack/plugins/rollup/server/plugin.ts
+++ b/x-pack/plugins/rollup/server/plugin.ts
@@ -36,8 +36,7 @@ import { registerRollupSearchStrategy } from './lib/search_strategies';
import { elasticsearchJsPlugin } from './client/elasticsearch_rollup';
import { isEsError } from './shared_imports';
import { formatEsError } from './lib/format_es_error';
-import { getCapabilitiesForRollupIndices } from './lib/map_capabilities';
-import { mergeCapabilitiesWithFields } from './lib/merge_capabilities_with_fields';
+import { getCapabilitiesForRollupIndices } from '../../../../src/plugins/data/server';
interface RollupContext {
client: ILegacyScopedClusterClient;
@@ -107,7 +106,6 @@ export class RollupPlugin implements Plugin {
isEsError,
formatEsError,
getCapabilitiesForRollupIndices,
- mergeCapabilitiesWithFields,
},
sharedImports: {
IndexPatternsFetcher,
diff --git a/x-pack/plugins/rollup/server/routes/api/index_patterns/index.ts b/x-pack/plugins/rollup/server/routes/api/index_patterns/index.ts
deleted file mode 100644
index 7bf525ca4aa98..0000000000000
--- a/x-pack/plugins/rollup/server/routes/api/index_patterns/index.ts
+++ /dev/null
@@ -1,12 +0,0 @@
-/*
- * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
- * or more contributor license agreements. Licensed under the Elastic License;
- * you may not use this file except in compliance with the Elastic License.
- */
-
-import { RouteDependencies } from '../../../types';
-import { registerFieldsForWildcardRoute } from './register_fields_for_wildcard_route';
-
-export function registerIndexPatternsRoutes(dependencies: RouteDependencies) {
- registerFieldsForWildcardRoute(dependencies);
-}
diff --git a/x-pack/plugins/rollup/server/routes/api/index_patterns/register_fields_for_wildcard_route.ts b/x-pack/plugins/rollup/server/routes/api/index_patterns/register_fields_for_wildcard_route.ts
deleted file mode 100644
index df9907fbf731a..0000000000000
--- a/x-pack/plugins/rollup/server/routes/api/index_patterns/register_fields_for_wildcard_route.ts
+++ /dev/null
@@ -1,142 +0,0 @@
-/*
- * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
- * or more contributor license agreements. Licensed under the Elastic License;
- * you may not use this file except in compliance with the Elastic License.
- */
-
-import { keyBy } from 'lodash';
-import { schema } from '@kbn/config-schema';
-import { Field } from '../../../lib/merge_capabilities_with_fields';
-import { RouteDependencies } from '../../../types';
-import type { IndexPatternsFetcher as IndexPatternsFetcherType } from '../../../../../../../src/plugins/data/server';
-
-const parseMetaFields = (metaFields: string | string[]) => {
- let parsedFields: string[] = [];
- if (typeof metaFields === 'string') {
- parsedFields = JSON.parse(metaFields);
- } else {
- parsedFields = metaFields;
- }
- return parsedFields;
-};
-
-const getFieldsForWildcardRequest = async (
- context: any,
- request: any,
- response: any,
- IndexPatternsFetcher: typeof IndexPatternsFetcherType
-) => {
- const { asCurrentUser } = context.core.elasticsearch.client;
- const indexPatterns = new IndexPatternsFetcher(asCurrentUser);
- const { pattern, meta_fields: metaFields } = request.query;
-
- let parsedFields: string[] = [];
- try {
- parsedFields = parseMetaFields(metaFields);
- } catch (error) {
- return response.badRequest({
- body: error,
- });
- }
-
- try {
- const fields = await indexPatterns.getFieldsForWildcard({
- pattern,
- metaFields: parsedFields,
- });
-
- return response.ok({
- body: { fields },
- headers: {
- 'content-type': 'application/json',
- },
- });
- } catch (error) {
- return response.notFound();
- }
-};
-
-/**
- * Get list of fields for rollup index pattern, in the format of regular index pattern fields
- */
-export const registerFieldsForWildcardRoute = ({
- router,
- license,
- lib: { isEsError, formatEsError, getCapabilitiesForRollupIndices, mergeCapabilitiesWithFields },
- sharedImports: { IndexPatternsFetcher },
-}: RouteDependencies) => {
- const querySchema = schema.object({
- pattern: schema.string(),
- meta_fields: schema.arrayOf(schema.string(), {
- defaultValue: [],
- }),
- params: schema.string({
- validate(value) {
- try {
- const params = JSON.parse(value);
- const keys = Object.keys(params);
- const { rollup_index: rollupIndex } = params;
-
- if (!rollupIndex) {
- return '[request query.params]: "rollup_index" is required';
- } else if (keys.length > 1) {
- const invalidParams = keys.filter((key) => key !== 'rollup_index');
- return `[request query.params]: ${invalidParams.join(', ')} is not allowed`;
- }
- } catch (err) {
- return '[request query.params]: expected JSON string';
- }
- },
- }),
- });
-
- router.get(
- {
- path: '/api/index_patterns/rollup/_fields_for_wildcard',
- validate: {
- query: querySchema,
- },
- },
- license.guardApiRoute(async (context, request, response) => {
- const { params, meta_fields: metaFields } = request.query;
-
- try {
- // Make call and use field information from response
- const { payload } = await getFieldsForWildcardRequest(
- context,
- request,
- response,
- IndexPatternsFetcher
- );
- const fields = payload.fields;
- const parsedParams = JSON.parse(params);
- const rollupIndex = parsedParams.rollup_index;
- const rollupFields: Field[] = [];
- const fieldsFromFieldCapsApi: { [key: string]: any } = keyBy(fields, 'name');
- const rollupIndexCapabilities = getCapabilitiesForRollupIndices(
- await context.rollup!.client.callAsCurrentUser('rollup.rollupIndexCapabilities', {
- indexPattern: rollupIndex,
- })
- )[rollupIndex].aggs;
-
- // Keep meta fields
- metaFields.forEach(
- (field: string) =>
- fieldsFromFieldCapsApi[field] && rollupFields.push(fieldsFromFieldCapsApi[field])
- );
-
- const mergedRollupFields = mergeCapabilitiesWithFields(
- rollupIndexCapabilities,
- fieldsFromFieldCapsApi,
- rollupFields
- );
- return response.ok({ body: { fields: mergedRollupFields } });
- } catch (err) {
- if (isEsError(err)) {
- return response.customError({ statusCode: err.statusCode, body: err });
- }
- return response.internalError({ body: err });
- }
- })
- );
-};
diff --git a/x-pack/plugins/rollup/server/routes/index.ts b/x-pack/plugins/rollup/server/routes/index.ts
index b25480855b4a2..322003c0ee325 100644
--- a/x-pack/plugins/rollup/server/routes/index.ts
+++ b/x-pack/plugins/rollup/server/routes/index.ts
@@ -6,13 +6,11 @@
import { RouteDependencies } from '../types';
-import { registerIndexPatternsRoutes } from './api/index_patterns';
import { registerIndicesRoutes } from './api/indices';
import { registerJobsRoutes } from './api/jobs';
import { registerSearchRoutes } from './api/search';
export function registerApiRoutes(dependencies: RouteDependencies) {
- registerIndexPatternsRoutes(dependencies);
registerIndicesRoutes(dependencies);
registerJobsRoutes(dependencies);
registerSearchRoutes(dependencies);
diff --git a/x-pack/plugins/rollup/server/types.ts b/x-pack/plugins/rollup/server/types.ts
index b167806cf8d5d..89e13e69c4da2 100644
--- a/x-pack/plugins/rollup/server/types.ts
+++ b/x-pack/plugins/rollup/server/types.ts
@@ -8,6 +8,7 @@ import { IRouter } from 'src/core/server';
import { UsageCollectionSetup } from 'src/plugins/usage_collection/server';
import { VisTypeTimeseriesSetup } from 'src/plugins/vis_type_timeseries/server';
+import { getCapabilitiesForRollupIndices } from 'src/plugins/data/server';
import { IndexManagementPluginSetup } from '../../index_management/server';
import { PluginSetupContract as FeaturesPluginSetup } from '../../features/server';
import { LicensingPluginSetup } from '../../licensing/server';
@@ -15,8 +16,6 @@ import { License } from './services';
import { IndexPatternsFetcher } from './shared_imports';
import { isEsError } from './shared_imports';
import { formatEsError } from './lib/format_es_error';
-import { getCapabilitiesForRollupIndices } from './lib/map_capabilities';
-import { mergeCapabilitiesWithFields } from './lib/merge_capabilities_with_fields';
export interface Dependencies {
indexManagement?: IndexManagementPluginSetup;
@@ -33,7 +32,6 @@ export interface RouteDependencies {
isEsError: typeof isEsError;
formatEsError: typeof formatEsError;
getCapabilitiesForRollupIndices: typeof getCapabilitiesForRollupIndices;
- mergeCapabilitiesWithFields: typeof mergeCapabilitiesWithFields;
};
sharedImports: {
IndexPatternsFetcher: typeof IndexPatternsFetcher;
diff --git a/x-pack/test/api_integration/apis/management/rollup/constants.js b/x-pack/test/api_integration/apis/management/rollup/constants.js
index fe899c4c10c88..0313434cf716c 100644
--- a/x-pack/test/api_integration/apis/management/rollup/constants.js
+++ b/x-pack/test/api_integration/apis/management/rollup/constants.js
@@ -5,7 +5,7 @@
*/
export const API_BASE_PATH = '/api/rollup';
-export const INDEX_PATTERNS_EXTENSION_BASE_PATH = '/api/index_patterns/rollup';
+export const INDEX_PATTERNS_EXTENSION_BASE_PATH = '/api/index_patterns';
export const ROLLUP_INDEX_NAME = 'rollup_index';
export const INDEX_TO_ROLLUP_MAPPINGS = {
properties: {
diff --git a/x-pack/test/api_integration/apis/management/rollup/index_patterns_extensions.js b/x-pack/test/api_integration/apis/management/rollup/index_patterns_extensions.js
index 357b952e7e66d..0a93e8b8bd1e3 100644
--- a/x-pack/test/api_integration/apis/management/rollup/index_patterns_extensions.js
+++ b/x-pack/test/api_integration/apis/management/rollup/index_patterns_extensions.js
@@ -26,7 +26,6 @@ export default function ({ getService }) {
describe('query params validation', () => {
let uri;
let body;
- let params;
it('"pattern" is required', async () => {
uri = `${BASE_URI}`;
@@ -36,62 +35,17 @@ export default function ({ getService }) {
);
});
- it('"params" is required', async () => {
- params = { pattern: 'foo' };
- uri = `${BASE_URI}?${stringify(params, { sort: false })}`;
- ({ body } = await supertest.get(uri).expect(400));
- expect(body.message).to.contain(
- '[request query.params]: expected value of type [string]'
- );
- });
-
- it('"params" must be a valid JSON string', async () => {
- params = { pattern: 'foo', params: 'foobarbaz' };
- uri = `${BASE_URI}?${stringify(params, { sort: false })}`;
- ({ body } = await supertest.get(uri).expect(400));
- expect(body.message).to.contain('[request query.params]: expected JSON string');
- });
-
- it('"params" requires a "rollup_index" property', async () => {
- params = { pattern: 'foo', params: JSON.stringify({}) };
- uri = `${BASE_URI}?${stringify(params, { sort: false })}`;
- ({ body } = await supertest.get(uri).expect(400));
- expect(body.message).to.contain('[request query.params]: "rollup_index" is required');
- });
-
- it('"params" only accepts a "rollup_index" property', async () => {
- params = {
- pattern: 'foo',
- params: JSON.stringify({ rollup_index: 'my_index', someProp: 'bar' }),
- };
- uri = `${BASE_URI}?${stringify(params, { sort: false })}`;
- ({ body } = await supertest.get(uri).expect(400));
- expect(body.message).to.contain('[request query.params]: someProp is not allowed');
- });
-
- it('"meta_fields" must be an Array', async () => {
- params = {
- pattern: 'foo',
- params: JSON.stringify({ rollup_index: 'bar' }),
- meta_fields: 'stringValue',
- };
- uri = `${BASE_URI}?${stringify(params, { sort: false })}`;
- ({ body } = await supertest.get(uri).expect(400));
- expect(body.message).to.contain(
- '[request query.meta_fields]: could not parse array value from json input'
- );
- });
-
it('should return 404 the rollup index to query does not exist', async () => {
uri = `${BASE_URI}?${stringify(
{
pattern: 'foo',
- params: JSON.stringify({ rollup_index: 'bar' }),
+ type: 'rollup',
+ rollup_index: 'bar',
},
{ sort: false }
)}`;
({ body } = await supertest.get(uri).expect(404));
- expect(body.message).to.contain('[index_not_found_exception] no such index [bar]');
+ expect(body.message).to.contain('No indices match pattern "foo"');
});
});
@@ -105,7 +59,8 @@ export default function ({ getService }) {
// Query for wildcard
const params = {
pattern: indexName,
- params: JSON.stringify({ rollup_index: rollupIndex }),
+ type: 'rollup',
+ rollup_index: rollupIndex,
};
const uri = `${BASE_URI}?${stringify(params, { sort: false })}`;
const { body } = await supertest.get(uri).expect(200);