From a5bdfec0de702fe593c76bfb5559e5b57a712f62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Wed, 2 Aug 2017 16:52:43 +0200 Subject: [PATCH] ES: return .raw fields in field lookups, closes #8975 --- .../plugins/datasource/elasticsearch/datasource.js | 11 +++++++++-- .../elasticsearch/specs/datasource_specs.ts | 6 +++++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/public/app/plugins/datasource/elasticsearch/datasource.js b/public/app/plugins/datasource/elasticsearch/datasource.js index 5f3ce0fa361..9ea679d5cc5 100644 --- a/public/app/plugins/datasource/elasticsearch/datasource.js +++ b/public/app/plugins/datasource/elasticsearch/datasource.js @@ -272,10 +272,17 @@ function (angular, _, moment, kbn, ElasticQueryBuilder, IndexPattern, ElasticRes var subObj = obj[key]; // Check mapping field for nested fields - if (subObj.hasOwnProperty('properties')) { + if (_.isObject(subObj.properties)) { fieldNameParts.push(key); getFieldsRecursively(subObj.properties); - } else { + } + + if (_.isObject(subObj.fields)) { + fieldNameParts.push(key); + getFieldsRecursively(subObj.fields); + } + + if (_.isString(subObj.type)) { var fieldName = fieldNameParts.concat(key).join('.'); // Hide meta-fields and check field type diff --git a/public/app/plugins/datasource/elasticsearch/specs/datasource_specs.ts b/public/app/plugins/datasource/elasticsearch/specs/datasource_specs.ts index d0133256982..0838dc33654 100644 --- a/public/app/plugins/datasource/elasticsearch/specs/datasource_specs.ts +++ b/public/app/plugins/datasource/elasticsearch/specs/datasource_specs.ts @@ -129,7 +129,10 @@ describe('ElasticDatasource', function() { '@timestamp': {type: 'date'}, beat: { properties: { - name: {type: 'string'}, + name: { + fields: {raw: {type: 'keyword'}}, + type: 'string' + }, hostname: {type: 'string'}, } }, @@ -169,6 +172,7 @@ describe('ElasticDatasource', function() { var fields = _.map(fieldObjects, 'text'); expect(fields).to.eql([ '@timestamp', + 'beat.name.raw', 'beat.name', 'beat.hostname', 'system.cpu.system',