Skip to content

Commit

Permalink
[7.17] Remove deprecated "type" field (#122919)
Browse files Browse the repository at this point in the history
* fix packages tests

* remove from es-archiver

* do no include deprecated type field

* remove another usage

* Remove _type from saved_objects_management archives

Co-authored-by: Rudolf Meijering <[email protected]>
  • Loading branch information
Mikhail Shustov and rudolf authored Jan 13, 2022
1 parent 686ce4b commit 63f7741
Show file tree
Hide file tree
Showing 6 changed files with 385 additions and 392 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ interface SearchResponses {
total: number;
hits: Array<{
_index: string;
_type: string;
_id: string;
_source: Record<string, unknown>;
}>;
Expand Down Expand Up @@ -59,9 +58,9 @@ describe('esArchiver: createGenerateDocRecordsStream()', () => {
hits: {
total: 5,
hits: [
{ _index: 'foo', _type: '_doc', _id: '0', _source: {} },
{ _index: 'foo', _type: '_doc', _id: '1', _source: {} },
{ _index: 'foo', _type: '_doc', _id: '2', _source: {} },
{ _index: 'foo', _id: '0', _source: {} },
{ _index: 'foo', _id: '1', _source: {} },
{ _index: 'foo', _id: '2', _source: {} },
],
},
},
Expand All @@ -71,8 +70,8 @@ describe('esArchiver: createGenerateDocRecordsStream()', () => {
hits: {
total: 5,
hits: [
{ _index: 'foo', _type: '_doc', _id: '3', _source: {} },
{ _index: 'foo', _type: '_doc', _id: '4', _source: {} },
{ _index: 'foo', _id: '3', _source: {} },
{ _index: 'foo', _id: '4', _source: {} },
],
},
},
Expand All @@ -84,8 +83,8 @@ describe('esArchiver: createGenerateDocRecordsStream()', () => {
hits: {
total: 2,
hits: [
{ _index: 'bar', _type: '_doc', _id: '0', _source: {} },
{ _index: 'bar', _type: '_doc', _id: '1', _source: {} },
{ _index: 'bar', _id: '0', _source: {} },
{ _index: 'bar', _id: '1', _source: {} },
],
},
},
Expand All @@ -108,7 +107,6 @@ describe('esArchiver: createGenerateDocRecordsStream()', () => {
createMapStream((record: any) => {
expect(record).toHaveProperty('type', 'doc');
expect(record.value.source).toEqual({});
expect(record.value.type).toBe('_doc');
expect(record.value.index).toMatch(/^(foo|bar)$/);
expect(record.value.id).toMatch(/^\d+$/);
return `${record.value.index}:${record.value.id}`;
Expand Down Expand Up @@ -224,7 +222,7 @@ describe('esArchiver: createGenerateDocRecordsStream()', () => {

describe('keepIndexNames', () => {
it('changes .kibana* index names if keepIndexNames is not enabled', async () => {
const hits = [{ _index: '.kibana_7.16.0_001', _type: '_doc', _id: '0', _source: {} }];
const hits = [{ _index: '.kibana_7.16.0_001', _id: '0', _source: {} }];
const responses = {
['.kibana_7.16.0_001']: [{ body: { hits: { hits, total: hits.length } } }],
};
Expand All @@ -248,7 +246,7 @@ describe('esArchiver: createGenerateDocRecordsStream()', () => {
});

it('does not change non-.kibana* index names if keepIndexNames is not enabled', async () => {
const hits = [{ _index: '.foo', _type: '_doc', _id: '0', _source: {} }];
const hits = [{ _index: '.foo', _id: '0', _source: {} }];
const responses = {
['.foo']: [{ body: { hits: { hits, total: hits.length } } }],
};
Expand All @@ -272,7 +270,7 @@ describe('esArchiver: createGenerateDocRecordsStream()', () => {
});

it('does not change .kibana* index names if keepIndexNames is enabled', async () => {
const hits = [{ _index: '.kibana_7.16.0_001', _type: '_doc', _id: '0', _source: {} }];
const hits = [{ _index: '.kibana_7.16.0_001', _id: '0', _source: {} }];
const responses = {
['.kibana_7.16.0_001']: [{ body: { hits: { hits, total: hits.length } } }],
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ export function createGenerateDocRecordsStream({
// when it is loaded it can skip migration, if possible
index:
hit._index.startsWith('.kibana') && !keepIndexNames ? '.kibana_1' : hit._index,
type: hit._type,
id: hit._id,
source: hit._source,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ export function createIndexDocRecordsStream(
ops.set(body, {
[operation]: {
_index: doc.index,
_type: doc.type,
_id: doc.id,
},
});
Expand Down
1 change: 0 additions & 1 deletion packages/kbn-es-archiver/src/lib/indices/kibana_index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ export async function cleanKibanaIndices({
bool: {
must_not: {
ids: {
type: '_doc',
values: ['space:default'],
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"type": "doc",
"value": {
"index": ".kibana",
"type": "doc",
"type": "_doc",
"id": "dashboard:dash-with-missing-refs",
"source": {
"dashboard": {
Expand Down
Loading

0 comments on commit 63f7741

Please sign in to comment.