Skip to content

Commit

Permalink
Update mappings for kibana index (#9280)
Browse files Browse the repository at this point in the history
* Update buildNum mapping from string/not_analyzed to keyword

* Change index-pattern type mappings from string -> keyword

* Updating unit test

* Updating string mappings for various saved object types

* Fixing mapping for index pattern title field

This needs to be text because other types in the Kibana index also have a field named "title", whose mapping needs to be text. We can't have the same field have different mappings in different types within the same index.

* Removing unused files

* Removing test file because corresponding source file is gone now
  • Loading branch information
ycombinator authored Dec 2, 2016
1 parent 083d564 commit d635c11
Show file tree
Hide file tree
Showing 13 changed files with 31 additions and 222 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,7 @@ describe('plugins/elasticsearch', function () {
expect(params.body.mappings.config.properties)
.to.have.property('buildNum');
expect(params.body.mappings.config.properties.buildNum)
.to.have.property('type', 'string');
expect(params.body.mappings.config.properties.buildNum)
.to.have.property('index', 'not_analyzed');
.to.have.property('type', 'keyword');
});
});

Expand Down
3 changes: 1 addition & 2 deletions src/core_plugins/elasticsearch/lib/kibana_index_mappings.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ export const mappings = {
config: {
properties: {
buildNum: {
type: 'string',
index: 'not_analyzed'
type: 'keyword'
}
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,20 +46,20 @@ module.factory('SavedDashboard', function (courier, config) {

// if type:dashboard has no mapping, we push this mapping into ES
SavedDashboard.mapping = {
title: 'string',
title: 'text',
hits: 'integer',
description: 'string',
panelsJSON: 'string',
optionsJSON: 'string',
uiStateJSON: 'string',
description: 'text',
panelsJSON: 'keyword',
optionsJSON: 'keyword',
uiStateJSON: 'keyword',
version: 'integer',
timeRestore: 'boolean',
timeTo: 'string',
timeFrom: 'string',
timeTo: 'keyword',
timeFrom: 'keyword',
refreshInterval: {
type: 'object',
properties: {
display: {type: 'string'},
display: {type: 'keyword'},
pause: { type: 'boolean'},
section: { type: 'integer'},
value: { type: 'integer'}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ module.factory('SavedSearch', function (courier) {
SavedSearch.type = 'search';

SavedSearch.mapping = {
title: 'string',
description: 'string',
title: 'text',
description: 'text',
hits: 'integer',
columns: 'string',
sort: 'string',
columns: 'keyword',
sort: 'keyword',
version: 'integer'
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@ uiModules
SavedVis.type = 'visualization';

SavedVis.mapping = {
title: 'string',
title: 'text',
visState: 'json',
uiStateJSON: 'string',
description: 'string',
savedSearchId: 'string',
uiStateJSON: 'keyword',
description: 'text',
savedSearchId: 'keyword',
version: 'integer'
};

Expand Down

This file was deleted.

50 changes: 0 additions & 50 deletions src/core_plugins/kibana/server/lib/init_default_field_props.js

This file was deleted.

38 changes: 0 additions & 38 deletions src/core_plugins/kibana/server/lib/mapping_overrides.js

This file was deleted.

10 changes: 5 additions & 5 deletions src/core_plugins/timelion/public/services/_saved_sheet.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@ module.factory('SavedSheet', function (courier, config) {

// if type:sheet has no mapping, we push this mapping into ES
SavedSheet.mapping = {
title: 'string',
title: 'text',
hits: 'integer',
description: 'string',
timelion_sheet: 'string',
timelion_interval: 'string',
timelion_other_interval: 'string',
description: 'text',
timelion_sheet: 'keyword',
timelion_interval: 'keyword',
timelion_other_interval: 'keyword',
timelion_chart_height: 'integer',
timelion_columns: 'integer',
timelion_rows: 'integer',
Expand Down
2 changes: 1 addition & 1 deletion src/ui/public/courier/saved_object/saved_object.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export default function SavedObjectFactory(es, kbnIndex, Promise, Private, Notif
properties: {
// setup the searchSource mapping, even if it is not used but this type yet
searchSourceJSON: {
type: 'string'
type: 'keyword'
}
}
};
Expand Down
8 changes: 4 additions & 4 deletions src/ui/public/index_patterns/_index_pattern.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@ export default function IndexPatternFactory(Private, Notifier, config, kbnIndex,
});

const mapping = mappingSetup.expandShorthand({
title: 'string',
timeFieldName: 'string',
title: 'text',
timeFieldName: 'keyword',
notExpandable: 'boolean',
intervalName: 'string',
intervalName: 'keyword',
fields: 'json',
sourceFilters: 'json',
fieldFormatMap: {
type: 'string',
type: 'keyword',
_serialize(map = {}) {
const serialized = _.transform(map, serialize);
return _.isEmpty(serialized) ? undefined : angular.toJson(serialized);
Expand Down
4 changes: 2 additions & 2 deletions src/ui/public/utils/__tests__/mapping_setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ describe('ui/utils/mapping_setup', function () {
});

context('when type is json', function () {
it('returned object is type string', function () {
it('returned object is type keyword', function () {
const mapping = mappingSetup.expandShorthand({ foo: 'json' });
expect(mapping.foo.type).to.be('string');
expect(mapping.foo.type).to.be('keyword');
});

it('returned object has _serialize function', function () {
Expand Down
2 changes: 1 addition & 1 deletion src/ui/public/utils/mapping_setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ define(function () {
if (typeof val === 'string') val = { type: val };

if (val.type === 'json') {
val.type = 'string';
val.type = 'keyword';
val._serialize = json._serialize;
val._deserialize = json._deserialize;
}
Expand Down

0 comments on commit d635c11

Please sign in to comment.