Skip to content

Commit

Permalink
[migrations] Fetch additional mappings with types
Browse files Browse the repository at this point in the history
Follow-up to #28497

Since elastic/elasticsearch#37285 has been merged, it's
aparent there are a couple more places we need to specify include_type_name
as a stop-gap until #23650 is completed

Signed-off-by: Tyler Smalley <[email protected]>
  • Loading branch information
Tyler Smalley committed Jan 15, 2019
1 parent 77a349b commit 90dede6
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
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 @@ -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

0 comments on commit 90dede6

Please sign in to comment.