From 056a67f5a4e0a7300271813f289774b3c27119c8 Mon Sep 17 00:00:00 2001 From: David Roberts Date: Wed, 9 Sep 2020 12:59:34 +0100 Subject: [PATCH] [ML] Account for "properties" layer in find_file_structure mappings This is the UI side companion for elastic/elasticsearch#62158 Previously the "mappings" field of the response from the find_file_structure endpoint was not a drop-in for the mappings format of the create index endpoint - the "properties" layer was missing. The reason for omitting it initially was that the assumption was that the find_file_structure endpoint would only ever return very simple mappings without any nested objects. However, this will not be true in the future, as we will improve mappings detection for complex JSON objects. As a first step it makes sense to move the returned mappings closer to the standard format. --- x-pack/plugins/ml/common/types/file_datavisualizer.ts | 4 +++- .../ml/server/models/file_data_visualizer/import_data.ts | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/x-pack/plugins/ml/common/types/file_datavisualizer.ts b/x-pack/plugins/ml/common/types/file_datavisualizer.ts index c997a4e24f868..f8ac7ac0b663f 100644 --- a/x-pack/plugins/ml/common/types/file_datavisualizer.ts +++ b/x-pack/plugins/ml/common/types/file_datavisualizer.ts @@ -84,7 +84,9 @@ export interface Settings { } export interface Mappings { - [key: string]: any; + properties: { + [key: string]: any; + }; } export interface IngestPipelineWrapper { diff --git a/x-pack/plugins/ml/server/models/file_data_visualizer/import_data.ts b/x-pack/plugins/ml/server/models/file_data_visualizer/import_data.ts index 6108454c08aa7..4bf2ade04d356 100644 --- a/x-pack/plugins/ml/server/models/file_data_visualizer/import_data.ts +++ b/x-pack/plugins/ml/server/models/file_data_visualizer/import_data.ts @@ -89,12 +89,12 @@ export function importDataProvider({ asCurrentUser }: IScopedClusterClient) { } async function createIndex(index: string, settings: Settings, mappings: Mappings) { - const body: { mappings: Mappings; settings?: Settings } = { + const body: { mappings: Mappings } = { mappings: { _meta: { created_by: INDEX_META_DATA_CREATED_BY, }, - properties: mappings, + properties: mappings.properties, }, };