Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] ES7 upgrade-- remove doc #28757

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/es_archiver/lib/docs/generate_doc_records_stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ export function createGenerateDocRecordsStream(client, stats) {
type: 'doc',
value: {
index: hit._index,
type: hit._type,
id: hit._id,
source: hit._source,
}
Expand Down
1 change: 0 additions & 1 deletion src/es_archiver/lib/docs/index_doc_records_stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ export function createIndexDocRecordsStream(client, stats) {
{
index: {
_index: doc.index,
_type: doc.type,
_id: doc.id,
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export function createGenerateIndexRecordsStream(client, stats) {
});

const { [index]: { aliases } } = await client.indices.getAlias({ index });
const { settings, mappings } = resp[index];
const { settings, mappings } = resp;

stats.archivedIndex(index, { settings, mappings });
callback(null, {
Expand Down
2 changes: 0 additions & 2 deletions src/es_archiver/lib/indices/kibana_index.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@ async function getKibanaStatuses({ kibanaUrl }) {
export async function createDefaultSpace({ index, client }) {
await client.index({
index,
type: 'doc',
id: 'space:default',
body: {
type: 'space',
Expand Down Expand Up @@ -181,7 +180,6 @@ export async function cleanKibanaIndices({ client, stats, log, kibanaUrl }) {
bool: {
must_not: {
ids: {
type: 'doc',
values: ['space:default']
}
}
Expand Down
1 change: 0 additions & 1 deletion src/server/mappings/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

export {
getTypes,
getRootType,
getProperty,
getRootProperties,
getRootPropertiesObjects,
Expand Down
4 changes: 1 addition & 3 deletions src/server/mappings/lib/get_property.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@

import toPath from 'lodash/internal/toPath';

import { getRootType } from './get_root_type';

/**
* Recursively read properties from the mapping object of type "object"
* until the `path` is resolved.
Expand Down Expand Up @@ -53,7 +51,7 @@ function getPropertyMappingFromObjectMapping(mapping, path) {
*/
export function getProperty(mappings, path) {
return getPropertyMappingFromObjectMapping(
mappings[getRootType(mappings)],
mappings,
toPath(path)
);
}
6 changes: 1 addition & 5 deletions src/server/mappings/lib/get_root_properties.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
* under the License.
*/

import { getRootType } from './get_root_type';

/**
* Get the property mappings for the root type in the EsMappingsDsl
*
Expand All @@ -37,9 +35,7 @@ import { getRootType } from './get_root_type';
* @param {EsMappingsDsl} mappings
* @return {EsPropertyMappings}
*/
export function getRootProperties(mappings) {
const mapping = mappings[getRootType(mappings)];

export function getRootProperties(mapping) {
if (mapping.type !== 'object' && !mapping.properties) {
throw new TypeError('Unable to get property names non-object root mapping');
}
Expand Down
38 changes: 0 additions & 38 deletions src/server/mappings/lib/get_root_type.js

This file was deleted.

1 change: 0 additions & 1 deletion src/server/mappings/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,5 @@

export { getProperty } from './get_property';
export { getTypes } from './get_types';
export { getRootType } from './get_root_type';
export { getRootProperties } from './get_root_properties';
export { getRootPropertiesObjects } from './get_root_properties_objects';
4 changes: 1 addition & 3 deletions src/server/sample_data/routes/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,7 @@ export const createInstallRoute = () => ({
}
},
mappings: {
_doc: {
properties: dataIndexConfig.fields
}
properties: dataIndexConfig.fields
}
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,34 @@

exports[`buildActiveMappings combines all mappings and includes core mappings 1`] = `
Object {
"doc": Object {
"dynamic": "strict",
"properties": Object {
"aaa": Object {
"type": "text",
},
"bbb": Object {
"type": "long",
},
"config": Object {
"dynamic": "true",
"properties": Object {
"buildNum": Object {
"type": "keyword",
},
"dynamic": "strict",
"properties": Object {
"aaa": Object {
"type": "text",
},
"bbb": Object {
"type": "long",
},
"config": Object {
"dynamic": "true",
"properties": Object {
"buildNum": Object {
"type": "keyword",
},
},
"migrationVersion": Object {
"dynamic": "true",
"type": "object",
},
"namespace": Object {
"type": "keyword",
},
"type": Object {
"type": "keyword",
},
"updated_at": Object {
"type": "date",
},
},
"migrationVersion": Object {
"dynamic": "true",
"type": "object",
},
"namespace": Object {
"type": "keyword",
},
"type": Object {
"type": "keyword",
},
"updated_at": Object {
"type": "date",
},
},
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ Array [
"index": Object {
"_id": "niceguy:fredrogers",
"_index": ".myalias",
"_type": "doc",
},
},
Object {
Expand All @@ -25,7 +24,6 @@ Array [
"index": Object {
"_id": "badguy:rickygervais",
"_index": ".myalias",
"_type": "doc",
},
},
Object {
Expand Down
48 changes: 22 additions & 26 deletions src/server/saved_objects/migrations/core/build_active_mappings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,8 @@ export function buildActiveMappings({
}): IndexMapping {
const mapping = defaultMapping();
return _.cloneDeep({
doc: {
...mapping.doc,
properties: validateAndMerge(mapping.doc.properties, properties),
},
...mapping,
properties: validateAndMerge(mapping.properties, properties),
});
}

Expand All @@ -53,30 +51,28 @@ export function buildActiveMappings({
*/
function defaultMapping(): IndexMapping {
return {
doc: {
dynamic: 'strict',
properties: {
config: {
dynamic: 'true',
properties: {
buildNum: {
type: 'keyword',
},
dynamic: 'strict',
properties: {
config: {
dynamic: 'true',
properties: {
buildNum: {
type: 'keyword',
},
},
migrationVersion: {
dynamic: 'true',
type: 'object',
},
type: {
type: 'keyword',
},
namespace: {
type: 'keyword',
},
updated_at: {
type: 'date',
},
},
migrationVersion: {
dynamic: 'true',
type: 'object',
},
type: {
type: 'keyword',
},
namespace: {
type: 'keyword',
},
updated_at: {
type: 'date',
},
},
};
Expand Down
18 changes: 3 additions & 15 deletions src/server/saved_objects/migrations/core/call_cluster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export interface CallCluster {
(path: 'indices.create' | 'indices.delete', opts: IndexCreationOpts): Promise<any>;
(path: 'indices.exists', opts: IndexOpts): Promise<boolean>;
(path: 'indices.existsAlias', opts: { name: string }): Promise<boolean>;
(path: 'indices.get', opts: IndicesGetOptions): Promise<IndicesInfo | NotFound>;
(path: 'indices.get', opts: IndexOpts & Ignorable): Promise<IndicesInfo | NotFound>;
(path: 'indices.getAlias', opts: { name: string } & Ignorable): Promise<AliasResult | NotFound>;
(path: 'indices.getMapping', opts: IndexOpts): Promise<MappingResult>;
(path: 'indices.getSettings', opts: IndexOpts): Promise<IndexSettingsResult>;
Expand Down Expand Up @@ -60,14 +60,11 @@ export interface CountOpts {
query: object;
};
index: string;
type: string;
}

export interface PutMappingOpts {
body: DocMapping;
body: IndexMapping;
index: string;
type: string;
include_type_name?: boolean;
}

export interface PutTemplateOpts {
Expand All @@ -88,7 +85,6 @@ export interface IndexOpts {

export interface IndexCreationOpts {
index: string;
include_type_name?: boolean;
body?: {
mappings?: IndexMapping;
settings?: {
Expand Down Expand Up @@ -129,10 +125,6 @@ export interface ScrollOpts {
scrollId: string;
}

export interface IndicesGetOptions extends IndexOpts, Ignorable {
include_type_name?: boolean;
}

///////////////////////////////////////////////////////////////////
// callCluster result type definitions
///////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -210,11 +202,7 @@ export interface MappingProperties {
[type: string]: any;
}

export interface DocMapping {
export interface IndexMapping {
dynamic: string;
properties: MappingProperties;
}

export interface IndexMapping {
doc: DocMapping;
}
Loading