From 76b94b81857a5ba26b881f9ffbf9c074bb68bb0d Mon Sep 17 00:00:00 2001 From: ruflin Date: Wed, 5 Aug 2020 10:02:28 +0200 Subject: [PATCH] updating to use `data_stream` instead of `datastream` --- .../server/routes/data_streams/handlers.ts | 10 +++++----- .../epm/elasticsearch/template/template.ts | 16 ++++++++-------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/x-pack/plugins/ingest_manager/server/routes/data_streams/handlers.ts b/x-pack/plugins/ingest_manager/server/routes/data_streams/handlers.ts index 00fa3437e3b11..43ae2b72f6077 100644 --- a/x-pack/plugins/ingest_manager/server/routes/data_streams/handlers.ts +++ b/x-pack/plugins/ingest_manager/server/routes/data_streams/handlers.ts @@ -31,12 +31,12 @@ export const getListHandler: RequestHandler = async (context, request, response) must: [ { exists: { - field: 'datastream.namespace', + field: 'data_stream.namespace', }, }, { exists: { - field: 'datastream.dataset', + field: 'data_stream.dataset', }, }, ], @@ -54,19 +54,19 @@ export const getListHandler: RequestHandler = async (context, request, response) aggs: { dataset: { terms: { - field: 'datastream.dataset', + field: 'data_stream.dataset', size: 1, }, }, namespace: { terms: { - field: 'datastream.namespace', + field: 'data_stream.namespace', size: 1, }, }, type: { terms: { - field: 'datastream.type', + field: 'data_stream.type', size: 1, }, }, diff --git a/x-pack/plugins/ingest_manager/server/services/epm/elasticsearch/template/template.ts b/x-pack/plugins/ingest_manager/server/services/epm/elasticsearch/template/template.ts index 5d921c52ea713..71e49acf1766f 100644 --- a/x-pack/plugins/ingest_manager/server/services/epm/elasticsearch/template/template.ts +++ b/x-pack/plugins/ingest_manager/server/services/epm/elasticsearch/template/template.ts @@ -393,14 +393,14 @@ const updateExistingIndex = async ({ // are added in https://github.com/elastic/kibana/issues/66551. namespace value we will continue // to skip updating and assume the value in the index mapping is correct delete mappings.properties.stream; - delete mappings.properties.datastream; + delete mappings.properties.data_stream; - // get the datastream values from the index template to compose data stream name + // get the data_stream values from the index template to compose data stream name const indexMappings = await getIndexMappings(indexName, callCluster); - const datastream = indexMappings[indexName].mappings.properties.datastream.properties; - if (!datastream.type.value || !datastream.dataset.value || !datastream.namespace.value) - throw new Error(`datastream values are missing from the index template ${indexName}`); - const datastreamName = `${datastream.type.value}-${datastream.dataset.value}-${datastream.namespace.value}`; + const dataStream = indexMappings[indexName].mappings.properties.data_stream.properties; + if (!dataStream.type.value || !dataStream.dataset.value || !dataStream.namespace.value) + throw new Error(`data_stream values are missing from the index template ${indexName}`); + const dataStreamName = `${dataStream.type.value}-${dataStream.dataset.value}-${dataStream.namespace.value}`; // try to update the mappings first try { @@ -411,13 +411,13 @@ const updateExistingIndex = async ({ // if update fails, rollover data stream } catch (err) { try { - const path = `/${datastreamName}/_rollover`; + const path = `/${dataStreamName}/_rollover`; await callCluster('transport.request', { method: 'POST', path, }); } catch (error) { - throw new Error(`cannot rollover data stream ${datastreamName}`); + throw new Error(`cannot rollover data stream ${dataStreamName}`); } } // update settings after mappings was successful to ensure