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

[migrations] Fetch additional mappings with types #28729

Merged
merged 2 commits into from
Jan 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions src/server/saved_objects/migrations/core/call_cluster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ export interface PutMappingOpts {
body: DocMapping;
index: string;
type: string;
include_type_name?: boolean;
}

export interface PutTemplateOpts {
Expand All @@ -87,6 +88,7 @@ export interface IndexOpts {

export interface IndexCreationOpts {
index: string;
include_type_name?: boolean;
body?: {
mappings?: IndexMapping;
settings?: {
Expand Down
13 changes: 11 additions & 2 deletions src/server/saved_objects/migrations/core/elastic_index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -222,15 +222,24 @@ export async function migrationsUpToDate(
* @param {IndexMapping} mappings
*/
export function putMappings(callCluster: CallCluster, index: string, mappings: IndexMapping) {
return callCluster('indices.putMapping', { body: mappings.doc, index, type: ROOT_TYPE });
return callCluster('indices.putMapping', {
body: mappings.doc,
index,
type: ROOT_TYPE,
include_type_name: true,
});
}

export async function createIndex(
callCluster: CallCluster,
index: string,
mappings?: IndexMapping
) {
await callCluster('indices.create', { body: { mappings, settings }, index });
await callCluster('indices.create', {
body: { mappings, settings },
index,
include_type_name: true,
});
}

export async function deleteIndex(callCluster: CallCluster, index: string) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ describe('IndexMigrator', () => {
},
},
index: '.kibana_1',
include_type_name: true,
type: ROOT_TYPE,
});
});
Expand Down Expand Up @@ -89,6 +90,7 @@ describe('IndexMigrator', () => {
settings: { number_of_shards: 1, auto_expand_replicas: '0-1' },
},
index: '.kibana_1',
include_type_name: true,
});
});

Expand Down Expand Up @@ -175,6 +177,7 @@ describe('IndexMigrator', () => {
},
},
},
include_type_name: true,
});

await new IndexMigrator(opts).migrate();
Expand All @@ -201,6 +204,7 @@ describe('IndexMigrator', () => {
settings: { number_of_shards: 1, auto_expand_replicas: '0-1' },
},
index: '.kibana_2',
include_type_name: true,
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +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}`,
include_type_name: true,
body: {
template: index,
settings: {
Expand Down