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

Add explicit format parameter to docvalue_fields requests #22771

Merged
merged 7 commits into from
Sep 7, 2018
Merged
Show file tree
Hide file tree
Changes from 3 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
2 changes: 1 addition & 1 deletion src/ui/public/agg_types/__tests__/metrics/top_hit.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand Down
2 changes: 1 addition & 1 deletion src/ui/public/agg_types/metrics/top_hit.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
15 changes: 13 additions & 2 deletions src/ui/public/index_patterns/__tests__/_get_computed_fields.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 epoch_millis format', function () {
const docvalueFields = fn().docvalueFields;
const timestampField = docvalueFields.find((field) => field.field === '@timestamp');
expect(timestampField).to.have.property('format', 'epoch_millis');
});

it('should not request scripted date fields as docvalue_fields', function () {
Expand Down
8 changes: 7 additions & 1 deletion src/ui/public/index_patterns/_get_computed_fields.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: 'epoch_millis',
};
});

_.each(self.getScriptedFields(), function (field) {
scriptFields[field.name] = {
Expand Down