diff --git a/src/plugins/kibana/server/lib/__tests__/create_mappings_from_pattern_fields.js b/src/plugins/kibana/server/lib/__tests__/create_mappings_from_pattern_fields.js index cf4563458ecef..7444d38384638 100644 --- a/src/plugins/kibana/server/lib/__tests__/create_mappings_from_pattern_fields.js +++ b/src/plugins/kibana/server/lib/__tests__/create_mappings_from_pattern_fields.js @@ -39,21 +39,21 @@ describe('createMappingsFromPatternFields', function () { let mappings = createMappingsFromPatternFields(testFields); _.forEach(mappings, function (mapping) { - if (mapping.type !== 'string') { + if (mapping.type !== 'text') { expect(_.isEqual(mapping, { type: mapping.type, - index: 'not_analyzed', + index: true, doc_values: true })).to.be.ok(); } }); }); - it('should give strings a multi-field mapping', function () { + it('should give strings a multi-field mapping with a "text" base type', function () { let mappings = createMappingsFromPatternFields(testFields); _.forEach(mappings, function (mapping) { - if (mapping.type === 'string') { + if (mapping.type === 'text') { expect(mapping).to.have.property('fields'); } }); @@ -68,7 +68,7 @@ describe('createMappingsFromPatternFields', function () { expect(mappings.geo.properties).to.have.property('coordinates'); expect(_.isEqual(mappings.geo.properties.coordinates, { type: 'geo_point', - index: 'not_analyzed', + index: true, doc_values: true })).to.be.ok(); }); diff --git a/src/plugins/kibana/server/lib/create_mappings_from_pattern_fields.js b/src/plugins/kibana/server/lib/create_mappings_from_pattern_fields.js index d05e650991613..b9ee189e35c4a 100644 --- a/src/plugins/kibana/server/lib/create_mappings_from_pattern_fields.js +++ b/src/plugins/kibana/server/lib/create_mappings_from_pattern_fields.js @@ -13,10 +13,9 @@ module.exports = function createMappingsFromPatternFields(fields) { if (field.type === 'string') { mapping = { - type: 'string', - index: 'analyzed', + type: 'text', fields: { - raw: {type: 'string', index: 'not_analyzed', doc_values: true, ignore_above: 256} + raw: {type: 'keyword', ignore_above: 256} } }; } @@ -24,7 +23,7 @@ module.exports = function createMappingsFromPatternFields(fields) { const fieldType = field.type === 'number' ? 'double' : field.type; mapping = { type: fieldType, - index: 'not_analyzed', + index: true, doc_values: true }; } diff --git a/src/plugins/kibana/server/routes/api/ingest/register_post.js b/src/plugins/kibana/server/routes/api/ingest/register_post.js index fe944f5307055..a4e259d6efaed 100644 --- a/src/plugins/kibana/server/routes/api/ingest/register_post.js +++ b/src/plugins/kibana/server/routes/api/ingest/register_post.js @@ -58,10 +58,9 @@ module.exports = function registerPost(server) { match: '*', match_mapping_type: 'string', mapping: { - type: 'string', - index: 'analyzed', + type: 'text', fields: { - raw: {type: 'string', index: 'not_analyzed', doc_values: true, ignore_above: 256} + raw: {type: 'keyword', ignore_above: 256} } } } diff --git a/test/unit/api/ingest/_post.js b/test/unit/api/ingest/_post.js index d2e986ca176ac..06df94ec319aa 100644 --- a/test/unit/api/ingest/_post.js +++ b/test/unit/api/ingest/_post.js @@ -12,7 +12,12 @@ define(function (require) { }); bdd.afterEach(function () { - return request.del('/kibana/ingest/logstash-*'); + return request.del('/kibana/ingest/logstash-*') + .then(function () { + return scenarioManager.client.indices.delete({ + index: 'logstash-*' + }); + }); }); bdd.it('should return 400 for an invalid payload', function invalidPayload() { @@ -57,6 +62,29 @@ define(function (require) { }); }); + bdd.it('should successfully create new indices based on the template', function newIndices() { + return request.post('/kibana/ingest') + .send(createTestData()) + .expect(204) + .then(function () { + return scenarioManager.client.create({ + index: 'logstash-1', + type: 'foo', + id: '1', + body: { + ip: '192.168.1.1', + '@timestamp': '2015-09-20T10:28:22.684Z', + agent: 'Jack', + bytes: 9001, + geo: {coordinates: {lat: 43.07260861, lon: -92.61077833}} + } + }) + .then(function (response) { + expect(response.created).to.be.ok(); + }); + }); + }); + bdd.it('should provide defaults for field properties', function createTemplate() { return request.post('/kibana/ingest') .send(createTestData()) @@ -92,15 +120,15 @@ define(function (require) { .then(function (template) { var mappings = template['kibana-logstash-*'].mappings._default_.properties; expect(mappings).to.be.ok(); - expect(_.isEqual(mappings.ip, {index: 'not_analyzed', type: 'ip', doc_values: true})).to.be.ok(); - expect(_.isEqual(mappings['@timestamp'], {index: 'not_analyzed', type: 'date', doc_values: true})).to.be.ok(); - expect(_.isEqual(mappings.bytes, {index: 'not_analyzed', type: 'double', doc_values: true})).to.be.ok(); + expect(_.isEqual(mappings.ip, {index: true, type: 'ip', doc_values: true})).to.be.ok(); + expect(_.isEqual(mappings['@timestamp'], {index: true, type: 'date', doc_values: true})).to.be.ok(); + expect(_.isEqual(mappings.bytes, {index: true, type: 'double', doc_values: true})).to.be.ok(); // object fields are mapped as such, with individual mappings for each of their properties expect(_.isEqual(mappings.geo, { properties: { coordinates: { - index: 'not_analyzed', + index: true, type: 'geo_point', doc_values: true }