diff --git a/src/ui/public/agg_types/__tests__/metrics/top_hit.js b/src/ui/public/agg_types/__tests__/metrics/top_hit.js index a83053140f5cd..3e616391068d4 100644 --- a/src/ui/public/agg_types/__tests__/metrics/top_hit.js +++ b/src/ui/public/agg_types/__tests__/metrics/top_hit.js @@ -90,7 +90,7 @@ describe('Top hit metric', function () { it('requests both source and docvalues_fields for non-text aggregatable fields', function () { init({ field: 'bytes' }); expect(aggDsl.top_hits._source).to.be('bytes'); - expect(aggDsl.top_hits.docvalue_fields).to.eql([ 'bytes' ]); + expect(aggDsl.top_hits.docvalue_fields).to.eql([ { field: 'bytes', format: 'use_field_mapping' } ]); }); it('requests just source for aggregatable text fields', function () { diff --git a/src/ui/public/agg_types/metrics/top_hit.js b/src/ui/public/agg_types/metrics/top_hit.js index a20d88eafa520..498739373d078 100644 --- a/src/ui/public/agg_types/metrics/top_hit.js +++ b/src/ui/public/agg_types/metrics/top_hit.js @@ -62,7 +62,7 @@ export const topHitMetricAgg = new MetricAggType({ }; } else { if (field.readFromDocValues) { - output.params.docvalue_fields = [ field.name ]; + output.params.docvalue_fields = [ { field: field.name, format: 'use_field_mapping' } ]; } output.params._source = field.name === '_source' ? true : field.name; } diff --git a/src/ui/public/courier/search_source/search_source.js b/src/ui/public/courier/search_source/search_source.js index 3a56d6a1dbf54..a99534ed9307c 100644 --- a/src/ui/public/courier/search_source/search_source.js +++ b/src/ui/public/courier/search_source/search_source.js @@ -583,7 +583,9 @@ export function SearchSourceProvider(Promise, Private, config) { if (flatData.body._source) { // exclude source fields for this index pattern specified by the user const filter = fieldWildcardFilter(flatData.body._source.excludes); - flatData.body.docvalue_fields = flatData.body.docvalue_fields.filter(filter); + flatData.body.docvalue_fields = flatData.body.docvalue_fields.filter( + docvalueField => filter(docvalueField.field) + ); } // if we only want to search for certain fields diff --git a/src/ui/public/index_patterns/__tests__/_get_computed_fields.js b/src/ui/public/index_patterns/__tests__/_get_computed_fields.js index def3a4709875c..101032413cc2d 100644 --- a/src/ui/public/index_patterns/__tests__/_get_computed_fields.js +++ b/src/ui/public/index_patterns/__tests__/_get_computed_fields.js @@ -43,8 +43,19 @@ describe('get computed fields', function () { }); it('should request date fields as docvalue_fields', function () { - expect(fn().docvalueFields).to.contain('@timestamp'); - expect(fn().docvalueFields).to.not.contain('bytes'); + const docvalueFields = fn().docvalueFields; + const docvalueFieldNames = docvalueFields.map(field => field.field); + + expect(docvalueFields).to.have.length(3); + expect(docvalueFieldNames).to.contain('@timestamp'); + expect(docvalueFieldNames).to.contain('time'); + expect(docvalueFieldNames).to.contain('utc_time'); + }); + + it('should request date field doc values in date_time format', function () { + const docvalueFields = fn().docvalueFields; + const timestampField = docvalueFields.find((field) => field.field === '@timestamp'); + expect(timestampField).to.have.property('format', 'date_time'); }); it('should not request scripted date fields as docvalue_fields', function () { diff --git a/src/ui/public/index_patterns/_get_computed_fields.js b/src/ui/public/index_patterns/_get_computed_fields.js index 7af20d2ef3882..527ca74821eb3 100644 --- a/src/ui/public/index_patterns/_get_computed_fields.js +++ b/src/ui/public/index_patterns/_get_computed_fields.js @@ -25,7 +25,13 @@ export function getComputedFields() { const scriptFields = {}; let docvalueFields = []; - docvalueFields = _.map(_.reject(self.fields.byType.date, 'scripted'), 'name'); + docvalueFields = _.reject(self.fields.byType.date, 'scripted') + .map((dateField) => { + return { + field: dateField.name, + format: 'date_time', + }; + }); _.each(self.getScriptedFields(), function (field) { scriptFields[field.name] = {