diff --git a/packages/kbn-es/src/integration_tests/cluster.test.js b/packages/kbn-es/src/integration_tests/cluster.test.js index e74f94d92beee0..f2aa7f7ae3b7ff 100644 --- a/packages/kbn-es/src/integration_tests/cluster.test.js +++ b/packages/kbn-es/src/integration_tests/cluster.test.js @@ -139,10 +139,14 @@ describe('#installSnapshot()', () => { const cluster = new Cluster(log); await cluster.installSnapshot({ foo: 'bar' }); expect(installSnapshot).toHaveBeenCalledTimes(1); - expect(installSnapshot).toHaveBeenCalledWith({ - log, - foo: 'bar', - }); + expect(installSnapshot).toHaveBeenCalledWith( + // In es6.7, this is the literal object. In 7.0, it also + // contains "version": "7.0.0" + expect.objectContaining({ + log, + foo: 'bar', + }) + ); }); it('rejects if installSnapshot() rejects', async () => { diff --git a/src/es_archiver/lib/indices/create_index_stream.js b/src/es_archiver/lib/indices/create_index_stream.js index 886db90c49c6ee..8ef1d9de885d96 100644 --- a/src/es_archiver/lib/indices/create_index_stream.js +++ b/src/es_archiver/lib/indices/create_index_stream.js @@ -53,16 +53,20 @@ export function createCreateIndexStream({ client, stats, skipExisting, log, kiba await client.indices.create({ method: 'PUT', index, + include_type_name: true, body: { settings, mappings }, }); - if (index.startsWith('.kibana') && await isSpacesEnabled({ kibanaUrl })) { + if (index.startsWith('.kibana') && (await isSpacesEnabled({ kibanaUrl }))) { await createDefaultSpace({ index, client }); } stats.createdIndex(index, { settings }); } catch (err) { - if (get(err, 'body.error.type') !== 'resource_already_exists_exception' || attemptNumber >= 3) { + if ( + get(err, 'body.error.type') !== 'resource_already_exists_exception' || + attemptNumber >= 3 + ) { throw err; } @@ -104,6 +108,6 @@ export function createCreateIndexStream({ client, stats, skipExisting, log, kiba } catch (err) { callback(err); } - } + }, }); } diff --git a/src/server/sample_data/routes/install.js b/src/server/sample_data/routes/install.js index 2b4787a6dbe62f..7e5563aa5628e6 100644 --- a/src/server/sample_data/routes/install.js +++ b/src/server/sample_data/routes/install.js @@ -119,7 +119,7 @@ export const createInstallRoute = () => ({ } } }, - includeTypeName: true + include_type_name: true }; await callWithRequest(request, 'indices.create', createIndexParams); } catch (err) { diff --git a/src/server/saved_objects/migrations/core/call_cluster.ts b/src/server/saved_objects/migrations/core/call_cluster.ts index e027067e6d12a2..b68783e6ac0ee2 100644 --- a/src/server/saved_objects/migrations/core/call_cluster.ts +++ b/src/server/saved_objects/migrations/core/call_cluster.ts @@ -83,10 +83,12 @@ export interface PutTemplateOpts { export interface IndexOpts { index: string; + include_type_name?: boolean; } export interface IndexCreationOpts { index: string; + include_type_name?: boolean; body?: { mappings?: IndexMapping; settings?: { diff --git a/src/server/saved_objects/migrations/core/elastic_index.test.ts b/src/server/saved_objects/migrations/core/elastic_index.test.ts index 20af40efdc25a9..f568c1224dd641 100644 --- a/src/server/saved_objects/migrations/core/elastic_index.test.ts +++ b/src/server/saved_objects/migrations/core/elastic_index.test.ts @@ -642,7 +642,7 @@ describe('ElasticIndex', () => { expect(hasMigrations).toBeFalsy(); expect(callCluster.args).toEqual([ - ['indices.get', { ignore: [404], index: '.myalias', includeTypeName: true }], + ['indices.get', { ignore: [404], index: '.myalias', include_type_name: true }], ]); }); diff --git a/src/server/saved_objects/migrations/core/elastic_index.ts b/src/server/saved_objects/migrations/core/elastic_index.ts index c5dc6a9ba1a8f2..34ae9cb3670c32 100644 --- a/src/server/saved_objects/migrations/core/elastic_index.ts +++ b/src/server/saved_objects/migrations/core/elastic_index.ts @@ -52,7 +52,11 @@ export interface FullIndexInfo { * index mappings are somewhat what we expect. */ export async function fetchInfo(callCluster: CallCluster, index: string): Promise { - const result = await callCluster('indices.get', { ignore: [404], index, includeTypeName: true }); + const result = await callCluster('indices.get', { + ignore: [404], + index, + include_type_name: true, + }); if ((result as NotFound).status === 404) { return { @@ -229,7 +233,7 @@ export async function createIndex( await callCluster('indices.create', { body: { mappings, settings }, index, - includeTypeName: true, + include_type_name: true, }); } @@ -255,7 +259,7 @@ export async function convertToAlias( await callCluster('indices.create', { body: { mappings: info.mappings, settings }, index: info.indexName, - includeTypeName: true, + include_type_name: true, }); await reindex(callCluster, alias, info.indexName, batchSize); diff --git a/src/server/saved_objects/migrations/core/index_migrator.test.ts b/src/server/saved_objects/migrations/core/index_migrator.test.ts index aadc7c4189cb66..133033f9d259ee 100644 --- a/src/server/saved_objects/migrations/core/index_migrator.test.ts +++ b/src/server/saved_objects/migrations/core/index_migrator.test.ts @@ -89,7 +89,7 @@ describe('IndexMigrator', () => { settings: { number_of_shards: 1, auto_expand_replicas: '0-1' }, }, index: '.kibana_1', - includeTypeName: true, + include_type_name: true, }); }); @@ -181,7 +181,7 @@ describe('IndexMigrator', () => { await new IndexMigrator(opts).migrate(); sinon.assert.calledWith(callCluster, 'indices.create', { - includeTypeName: true, + include_type_name: true, body: { mappings: { doc: { diff --git a/src/server/saved_objects/service/create_saved_objects_service.js b/src/server/saved_objects/service/create_saved_objects_service.js index a80d949c1711e2..8b56daa1a33981 100644 --- a/src/server/saved_objects/service/create_saved_objects_service.js +++ b/src/server/saved_objects/service/create_saved_objects_service.js @@ -38,7 +38,7 @@ export function createSavedObjectsService(server, schema, serializer, migrator) const index = server.config().get('kibana.index'); await adminCluster.callWithInternalUser('indices.putTemplate', { name: `kibana_index_template:${index}`, - includeTypeName: true, + include_type_name: true, body: { template: index, settings: { diff --git a/src/ui/ui_settings/routes/__tests__/index_missing.js b/src/ui/ui_settings/routes/__tests__/index_missing.js index dab17e8b6406a9..1c58669afe13a2 100644 --- a/src/ui/ui_settings/routes/__tests__/index_missing.js +++ b/src/ui/ui_settings/routes/__tests__/index_missing.js @@ -20,11 +20,7 @@ import expect from 'expect.js'; import sinon from 'sinon'; -import { - getServices, - chance, - assertSinonMatch, -} from './lib'; +import { getServices, chance, assertSinonMatch } from './lib'; export function indexMissingSuite() { async function setup() { @@ -41,17 +37,18 @@ export function indexMissingSuite() { // but automatically by writing to es when index didn't exist async assertValidKibanaIndex() { const resp = await callCluster('indices.get', { - index: indexName + index: indexName, + include_type_name: true, }); - expect(resp[indexName].mappings).to.have.property('doc'); - expect(resp[indexName].mappings.doc.properties).to.have.keys( + const mappings = resp[indexName].mappings.doc; + expect(mappings.properties).to.have.keys( 'index-pattern', 'visualization', 'search', 'dashboard' ); - } + }, }; } @@ -61,7 +58,7 @@ export function indexMissingSuite() { const { statusCode, result } = await kbnServer.inject({ method: 'GET', - url: '/api/kibana/settings' + url: '/api/kibana/settings', }); expect(statusCode).to.be(200); @@ -72,9 +69,9 @@ export function indexMissingSuite() { }, foo: { userValue: 'bar', - isOverridden: true - } - } + isOverridden: true, + }, + }, }); }); }); @@ -88,24 +85,24 @@ export function indexMissingSuite() { method: 'POST', url: '/api/kibana/settings/defaultIndex', payload: { - value: defaultIndex - } + value: defaultIndex, + }, }); expect(statusCode).to.be(200); assertSinonMatch(result, { settings: { buildNum: { - userValue: sinon.match.number + userValue: sinon.match.number, }, defaultIndex: { - userValue: defaultIndex + userValue: defaultIndex, }, foo: { userValue: 'bar', - isOverridden: true - } - } + isOverridden: true, + }, + }, }); await assertValidKibanaIndex(); @@ -121,24 +118,24 @@ export function indexMissingSuite() { method: 'POST', url: '/api/kibana/settings', payload: { - changes: { defaultIndex } - } + changes: { defaultIndex }, + }, }); expect(statusCode).to.be(200); assertSinonMatch(result, { settings: { buildNum: { - userValue: sinon.match.number + userValue: sinon.match.number, }, defaultIndex: { - userValue: defaultIndex + userValue: defaultIndex, }, foo: { userValue: 'bar', - isOverridden: true - } - } + isOverridden: true, + }, + }, }); await assertValidKibanaIndex(); @@ -151,20 +148,20 @@ export function indexMissingSuite() { const { statusCode, result } = await kbnServer.inject({ method: 'DELETE', - url: '/api/kibana/settings/defaultIndex' + url: '/api/kibana/settings/defaultIndex', }); expect(statusCode).to.be(200); assertSinonMatch(result, { settings: { buildNum: { - userValue: sinon.match.number + userValue: sinon.match.number, }, foo: { userValue: 'bar', - isOverridden: true - } - } + isOverridden: true, + }, + }, }); await assertValidKibanaIndex(); diff --git a/test/api_integration/apis/saved_objects/migrations.js b/test/api_integration/apis/saved_objects/migrations.js index 06e40a380e0204..8f119ba01f1940 100644 --- a/test/api_integration/apis/saved_objects/migrations.js +++ b/test/api_integration/apis/saved_objects/migrations.js @@ -219,7 +219,7 @@ async function createIndex({ callCluster, index }) { }; await callCluster('indices.create', { index, - includeTypeName: true, + include_type_name: true, body: { mappings: { doc: { dynamic: 'strict', properties } } }, }); } diff --git a/x-pack/plugins/beats_management/server/lib/adapters/database/kibana_database_adapter.ts b/x-pack/plugins/beats_management/server/lib/adapters/database/kibana_database_adapter.ts index fae812708c5657..42251bf8dc2ed3 100644 --- a/x-pack/plugins/beats_management/server/lib/adapters/database/kibana_database_adapter.ts +++ b/x-pack/plugins/beats_management/server/lib/adapters/database/kibana_database_adapter.ts @@ -108,7 +108,7 @@ export class KibanaDatabaseAdapter implements DatabaseAdapter { const result = await this.callWithUser({ kind: 'internal' }, 'indices.putTemplate', { name, body: template, - includeTypeName: true, + include_type_name: true, }); return result; diff --git a/x-pack/plugins/index_lifecycle_management/server/routes/api/index/register_bootstrap_route.js b/x-pack/plugins/index_lifecycle_management/server/routes/api/index/register_bootstrap_route.js index ad449101cb4f5c..a28b1db809dfbd 100644 --- a/x-pack/plugins/index_lifecycle_management/server/routes/api/index/register_bootstrap_route.js +++ b/x-pack/plugins/index_lifecycle_management/server/routes/api/index/register_bootstrap_route.js @@ -12,6 +12,7 @@ import { licensePreRoutingFactory } from '../../../lib/license_pre_routing_facto async function bootstrap(callWithRequest, payload) { await callWithRequest('indices.create', { index: payload.indexName, + include_type_name: true, body: { aliases: { [payload.aliasName]: { diff --git a/x-pack/plugins/index_lifecycle_management/server/routes/api/templates/register_add_policy_route.js b/x-pack/plugins/index_lifecycle_management/server/routes/api/templates/register_add_policy_route.js index d4197b20abb767..21703ec3f1105f 100644 --- a/x-pack/plugins/index_lifecycle_management/server/routes/api/templates/register_add_policy_route.js +++ b/x-pack/plugins/index_lifecycle_management/server/routes/api/templates/register_add_policy_route.js @@ -14,7 +14,7 @@ import { licensePreRoutingFactory } from'../../../lib/license_pre_routing_factor import { merge } from 'lodash'; async function getIndexTemplate(callWithRequest, templateName) { - const response = await callWithRequest('indices.getTemplate', { name: templateName }); + const response = await callWithRequest('indices.getTemplate', { name: templateName, include_type_name: true }); return response[templateName]; } diff --git a/x-pack/plugins/index_management/server/routes/api/mapping/register_mapping_route.js b/x-pack/plugins/index_management/server/routes/api/mapping/register_mapping_route.js index 66ac668c9245dd..7a8bab4799d35f 100644 --- a/x-pack/plugins/index_management/server/routes/api/mapping/register_mapping_route.js +++ b/x-pack/plugins/index_management/server/routes/api/mapping/register_mapping_route.js @@ -20,7 +20,7 @@ function formatHit(hit, indexName) { async function fetchMapping(callWithRequest, indexName) { const params = { expand_wildcards: 'none', - includeTypeName: true, + include_type_name: true, index: indexName, }; diff --git a/x-pack/plugins/logstash/server/routes/api/upgrade/register_execute_route.js b/x-pack/plugins/logstash/server/routes/api/upgrade/register_execute_route.js index 7bdeb136576cb3..a29c07c1eb9718 100755 --- a/x-pack/plugins/logstash/server/routes/api/upgrade/register_execute_route.js +++ b/x-pack/plugins/logstash/server/routes/api/upgrade/register_execute_route.js @@ -25,6 +25,7 @@ async function executeUpgrade(callWithRequest) { return callWithRequest('indices.putMapping', { index: INDEX_NAMES.PIPELINES, type: TYPE_NAMES.PIPELINES, + include_type_name: true, body: { properties: { pipeline_settings: { diff --git a/x-pack/plugins/ml/server/models/file_data_visualizer/import_data.js b/x-pack/plugins/ml/server/models/file_data_visualizer/import_data.js index b604ff32fec3d1..86b1275b47b277 100644 --- a/x-pack/plugins/ml/server/models/file_data_visualizer/import_data.js +++ b/x-pack/plugins/ml/server/models/file_data_visualizer/import_data.js @@ -93,7 +93,7 @@ export function importDataProvider(callWithRequest) { body.settings = settings; } - await callWithRequest('indices.create', { index, body, includeTypeName: true }); + await callWithRequest('indices.create', { index, body, include_type_name: true }); } async function indexData(index, pipelineId, data) { diff --git a/x-pack/plugins/reporting/server/lib/esqueue/helpers/create_index.js b/x-pack/plugins/reporting/server/lib/esqueue/helpers/create_index.js index dae6883dd7d0cb..b795e75ba4be1d 100644 --- a/x-pack/plugins/reporting/server/lib/esqueue/helpers/create_index.js +++ b/x-pack/plugins/reporting/server/lib/esqueue/helpers/create_index.js @@ -89,7 +89,7 @@ export function createIndex(client, indexName, return client.indices.create({ index: indexName, body: body, - includeTypeName: true, + include_type_name: true, }) .then(() => true) .catch(err => { diff --git a/x-pack/plugins/task_manager/task_store.test.ts b/x-pack/plugins/task_manager/task_store.test.ts index 437cdf9f81a6e4..b3ebae4317b251 100644 --- a/x-pack/plugins/task_manager/task_store.test.ts +++ b/x-pack/plugins/task_manager/task_store.test.ts @@ -43,6 +43,7 @@ describe('TaskStore', () => { }, }, name: 'tasky', + include_type_name: true, }); }); diff --git a/x-pack/plugins/task_manager/task_store.ts b/x-pack/plugins/task_manager/task_store.ts index 65d43ec6131719..032a52ce0eb46c 100644 --- a/x-pack/plugins/task_manager/task_store.ts +++ b/x-pack/plugins/task_manager/task_store.ts @@ -129,6 +129,7 @@ export class TaskStore { // check if template exists const templateCheck = await this.callCluster('indices.getTemplate', { name: templateName, + include_type_name: true, filter_path: '*.version', }); // extract the existing version diff --git a/x-pack/plugins/upgrade_assistant/server/lib/reindexing/reindex_actions.ts b/x-pack/plugins/upgrade_assistant/server/lib/reindexing/reindex_actions.ts index d7bf1f7d04c69a..ddf073414ec54c 100644 --- a/x-pack/plugins/upgrade_assistant/server/lib/reindexing/reindex_actions.ts +++ b/x-pack/plugins/upgrade_assistant/server/lib/reindexing/reindex_actions.ts @@ -241,7 +241,7 @@ export const reindexActionsFactory = ( async getBooleanFieldPaths(indexName: string) { const results = await callCluster('indices.getMapping', { index: indexName, - includeTypeName: true, + include_type_name: true, }); const mapping = getSingleMappingType(results[indexName].mappings); diff --git a/x-pack/test/api_integration/apis/management/cross_cluster_replication/lib/es_index.js b/x-pack/test/api_integration/apis/management/cross_cluster_replication/lib/es_index.js index 7ff1737da02990..eb2a2b99013fa9 100644 --- a/x-pack/test/api_integration/apis/management/cross_cluster_replication/lib/es_index.js +++ b/x-pack/test/api_integration/apis/management/cross_cluster_replication/lib/es_index.js @@ -15,7 +15,7 @@ export const initElasticsearchIndicesHelpers = (es) => { const createIndex = (index = getRandomString()) => { indicesCreated.push(index); - return es.indices.create({ index }).then(() => index); + return es.indices.create({ index, include_type_name: true }).then(() => index); }; const deleteIndex = (index) => { diff --git a/x-pack/test/api_integration/apis/monitoring/common/mappings_exist.js b/x-pack/test/api_integration/apis/monitoring/common/mappings_exist.js index 8d78a150f28c21..b34d9578c1cb1c 100644 --- a/x-pack/test/api_integration/apis/monitoring/common/mappings_exist.js +++ b/x-pack/test/api_integration/apis/monitoring/common/mappings_exist.js @@ -48,7 +48,7 @@ export default function ({ getService }) { let mappings; before('load mappings', async () => { - const template = await es.indices.getTemplate({ name: indexTemplate }); + const template = await es.indices.getTemplate({ name: indexTemplate, include_type_name: true }); mappings = get(template, [indexTemplate, 'mappings', 'doc', 'properties']); });