Skip to content

Commit

Permalink
[data.search.aggs] Remove use_field_mapping from top hits agg (#71168)
Browse files Browse the repository at this point in the history
  • Loading branch information
lukeelmers authored Jul 14, 2020
1 parent 50f8db7 commit 7b026bb
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 12 deletions.
4 changes: 1 addition & 3 deletions src/plugins/data/public/search/aggs/metrics/top_hit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,7 @@ describe('Top hit metric', () => {
it('requests both source and docvalues_fields for non-text aggregatable fields', () => {
init({ fieldName: 'bytes', readFromDocValues: true });
expect(aggDsl.top_hits._source).toBe('bytes');
expect(aggDsl.top_hits.docvalue_fields).toEqual([
{ field: 'bytes', format: 'use_field_mapping' },
]);
expect(aggDsl.top_hits.docvalue_fields).toEqual([{ field: 'bytes' }]);
});

it('requests both source and docvalues_fields for date aggregatable fields', () => {
Expand Down
15 changes: 9 additions & 6 deletions src/plugins/data/public/search/aggs/metrics/top_hit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,15 @@ export const getTopHitMetricAgg = () => {
};
} else {
if (field.readFromDocValues) {
// always format date fields as date_time to avoid
// displaying unformatted dates like epoch_millis
// or other not-accepted momentjs formats
const format =
field.type === KBN_FIELD_TYPES.DATE ? 'date_time' : 'use_field_mapping';
output.params.docvalue_fields = [{ field: field.name, format }];
output.params.docvalue_fields = [
{
field: field.name,
// always format date fields as date_time to avoid
// displaying unformatted dates like epoch_millis
// or other not-accepted momentjs formats
...(field.type === KBN_FIELD_TYPES.DATE && { format: 'date_time' }),
},
];
}
output.params._source = field.name === '_source' ? true : field.name;
}
Expand Down
4 changes: 1 addition & 3 deletions test/functional/apps/visualize/_area_chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -246,9 +246,7 @@ export default function ({ getService, getPageObjects }) {
await inspector.close();
});

// Preventing ES Promotion for master (8.0)
// https://github.com/elastic/kibana/issues/64734
it.skip('does not scale top hit agg', async () => {
it('does not scale top hit agg', async () => {
const expectedTableData = [
['2015-09-20 00:00', '6', '9.035KB'],
['2015-09-20 01:00', '9', '5.854KB'],
Expand Down

0 comments on commit 7b026bb

Please sign in to comment.