Skip to content

Commit

Permalink
[ML] Account for "properties" layer in find_file_structure mappings
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
droberts195 committed Sep 9, 2020
1 parent 2a451c9 commit 056a67f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 3 additions & 1 deletion x-pack/plugins/ml/common/types/file_datavisualizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,9 @@ export interface Settings {
}

export interface Mappings {
[key: string]: any;
properties: {
[key: string]: any;
};
}

export interface IngestPipelineWrapper {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
};

Expand Down

0 comments on commit 056a67f

Please sign in to comment.