Skip to content

Commit

Permalink
updating to use data_stream instead of datastream
Browse files Browse the repository at this point in the history
  • Loading branch information
ruflin authored and skh committed Aug 5, 2020
1 parent e3e42a3 commit 76b94b8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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',
},
},
],
Expand All @@ -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,
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
Expand Down

0 comments on commit 76b94b8

Please sign in to comment.