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

Support Histogram Data Type #59387

Merged
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
3695d49
Added HISTOGRAM field type to Kbn and ES field types
ThomThomson Mar 4, 2020
505aee5
updated unit tests to reflect addition of Histogram field type
ThomThomson Mar 5, 2020
386debf
removed generated newline characters in shapshot.
ThomThomson Mar 5, 2020
aca230a
Merge branch 'master' of github.com:elastic/kibana into enhancement/p…
ThomThomson Mar 6, 2020
33d2708
Regenerated snapshots on OSX, hope that will help with the line endin…
ThomThomson Mar 6, 2020
e10b0d4
allow histogram fields in Percentiles Ranks
ThomThomson Mar 10, 2020
65fd7d4
Added functional tests for Histogram data type
ThomThomson Mar 12, 2020
b5a0367
Merge branch 'master' of github.com:elastic/kibana into enhancement/p…
ThomThomson Mar 12, 2020
0f96cfd
Added a new option to the KbnFieldType for fields that should only al…
ThomThomson Mar 13, 2020
d17d7c0
generated docs for data plugin changes
ThomThomson Mar 13, 2020
4fdd6c9
Merge branch 'master' of github.com:elastic/kibana into enhancement/p…
ThomThomson Mar 13, 2020
8e4c5f5
Merge branch 'master' into enhancement/preAggregatedHistogram
elasticmachine Mar 16, 2020
7246b98
Merge branch 'master' into enhancement/preAggregatedHistogram
elasticmachine Mar 16, 2020
5e0d39f
Merge branch 'master' into enhancement/preAggregatedHistogram
elasticmachine Mar 16, 2020
188947d
Merge branch 'master' into enhancement/preAggregatedHistogram
elasticmachine Mar 17, 2020
f37a765
fixed file name issue
ThomThomson Mar 17, 2020
277dc80
Merge branch 'master' of github.com:elastic/kibana into enhancement/p…
ThomThomson Mar 18, 2020
75e5ee1
Reverted all changes to filters in favor of adding them to a differen…
ThomThomson Mar 18, 2020
0354bbe
Merge branch 'master' of github.com:elastic/kibana into enhancement/p…
ThomThomson Mar 19, 2020
cb26162
Filtered histogram types out of the top_hit and cardinality aggregati…
ThomThomson Mar 19, 2020
78cfab7
Merge branch 'master' into enhancement/preAggregatedHistogram
elasticmachine Mar 23, 2020
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
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export declare enum ES_FIELD_TYPES
| GEO\_POINT | <code>&quot;geo_point&quot;</code> | |
| GEO\_SHAPE | <code>&quot;geo_shape&quot;</code> | |
| HALF\_FLOAT | <code>&quot;half_float&quot;</code> | |
| HISTOGRAM | <code>&quot;histogram&quot;</code> | |
| INTEGER | <code>&quot;integer&quot;</code> | |
| IP | <code>&quot;ip&quot;</code> | |
| KEYWORD | <code>&quot;keyword&quot;</code> | |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export declare enum KBN_FIELD_TYPES
| DATE | <code>&quot;date&quot;</code> | |
| GEO\_POINT | <code>&quot;geo_point&quot;</code> | |
| GEO\_SHAPE | <code>&quot;geo_shape&quot;</code> | |
| HISTOGRAM | <code>&quot;histogram&quot;</code> | |
| IP | <code>&quot;ip&quot;</code> | |
| MURMUR3 | <code>&quot;murmur3&quot;</code> | |
| NESTED | <code>&quot;nested&quot;</code> | |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export declare enum ES_FIELD_TYPES
| GEO\_POINT | <code>&quot;geo_point&quot;</code> | |
| GEO\_SHAPE | <code>&quot;geo_shape&quot;</code> | |
| HALF\_FLOAT | <code>&quot;half_float&quot;</code> | |
| HISTOGRAM | <code>&quot;histogram&quot;</code> | |
| INTEGER | <code>&quot;integer&quot;</code> | |
| IP | <code>&quot;ip&quot;</code> | |
| KEYWORD | <code>&quot;keyword&quot;</code> | |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export declare enum KBN_FIELD_TYPES
| DATE | <code>&quot;date&quot;</code> | |
| GEO\_POINT | <code>&quot;geo_point&quot;</code> | |
| GEO\_SHAPE | <code>&quot;geo_shape&quot;</code> | |
| HISTOGRAM | <code>&quot;histogram&quot;</code> | |
| IP | <code>&quot;ip&quot;</code> | |
| MURMUR3 | <code>&quot;murmur3&quot;</code> | |
| NESTED | <code>&quot;nested&quot;</code> | |
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ describe('utils/kbn_field_types', () => {
KBN_FIELD_TYPES.DATE,
KBN_FIELD_TYPES.GEO_POINT,
KBN_FIELD_TYPES.GEO_SHAPE,
KBN_FIELD_TYPES.HISTOGRAM,
KBN_FIELD_TYPES.IP,
KBN_FIELD_TYPES.MURMUR3,
KBN_FIELD_TYPES.NESTED,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,11 @@ export const createKbnFieldTypes = (): KbnFieldType[] => [
name: KBN_FIELD_TYPES._SOURCE,
esTypes: [ES_FIELD_TYPES._SOURCE],
}),
new KbnFieldType({
name: KBN_FIELD_TYPES.HISTOGRAM,
filterable: true,
esTypes: [ES_FIELD_TYPES.HISTOGRAM],
}),
new KbnFieldType({
name: KBN_FIELD_TYPES.CONFLICT,
}),
Expand Down
3 changes: 3 additions & 0 deletions src/plugins/data/common/kbn_field_types/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ export enum ES_FIELD_TYPES {
ATTACHMENT = 'attachment',
TOKEN_COUNT = 'token_count',
MURMUR3 = 'murmur3',

HISTOGRAM = 'histogram',
}

/** @public **/
Expand All @@ -77,4 +79,5 @@ export enum KBN_FIELD_TYPES {
CONFLICT = 'conflict',
OBJECT = 'object',
NESTED = 'nested',
HISTOGRAM = 'histogram',
}
4 changes: 4 additions & 0 deletions src/plugins/data/public/public.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,8 @@ export enum ES_FIELD_TYPES {
// (undocumented)
HALF_FLOAT = "half_float",
// (undocumented)
HISTOGRAM = "histogram",
// (undocumented)
_ID = "_id",
// (undocumented)
_INDEX = "_index",
Expand Down Expand Up @@ -1126,6 +1128,8 @@ export enum KBN_FIELD_TYPES {
// (undocumented)
GEO_SHAPE = "geo_shape",
// (undocumented)
HISTOGRAM = "histogram",
// (undocumented)
IP = "ip",
// (undocumented)
MURMUR3 = "murmur3",
Expand Down
3 changes: 3 additions & 0 deletions src/plugins/data/public/search/aggs/metrics/cardinality.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ export const cardinalityMetricAgg = new MetricAggType({
{
name: 'field',
type: 'field',
filterFieldTypes: Object.values(KBN_FIELD_TYPES).filter(
type => type !== KBN_FIELD_TYPES.HISTOGRAM
),
},
],
});
2 changes: 1 addition & 1 deletion src/plugins/data/public/search/aggs/metrics/median.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export const medianMetricAgg = new MetricAggType({
{
name: 'field',
type: 'field',
filterFieldTypes: [KBN_FIELD_TYPES.NUMBER, KBN_FIELD_TYPES.DATE],
filterFieldTypes: [KBN_FIELD_TYPES.NUMBER, KBN_FIELD_TYPES.DATE, KBN_FIELD_TYPES.HISTOGRAM],
write(agg, output) {
output.params.field = agg.getParam('field').name;
output.params.percents = [50];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export const percentileRanksMetricAgg = new MetricAggType<IPercentileRanksAggCon
{
name: 'field',
type: 'field',
filterFieldTypes: KBN_FIELD_TYPES.NUMBER,
filterFieldTypes: [KBN_FIELD_TYPES.NUMBER, KBN_FIELD_TYPES.HISTOGRAM],
},
{
name: 'values',
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/data/public/search/aggs/metrics/percentiles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export const percentilesMetricAgg = new MetricAggType<IPercentileAggConfig>({
{
name: 'field',
type: 'field',
filterFieldTypes: [KBN_FIELD_TYPES.NUMBER, KBN_FIELD_TYPES.DATE],
filterFieldTypes: [KBN_FIELD_TYPES.NUMBER, KBN_FIELD_TYPES.DATE, KBN_FIELD_TYPES.HISTOGRAM],
},
{
name: 'percents',
Expand Down
4 changes: 3 additions & 1 deletion src/plugins/data/public/search/aggs/metrics/top_hit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@ export const topHitMetricAgg = new MetricAggType({
name: 'field',
type: 'field',
onlyAggregatable: false,
filterFieldTypes: '*',
filterFieldTypes: Object.values(KBN_FIELD_TYPES).filter(
type => type !== KBN_FIELD_TYPES.HISTOGRAM
),
write(agg, output) {
const field = agg.getParam('field');
output.params = {};
Expand Down
4 changes: 4 additions & 0 deletions src/plugins/data/server/server.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,8 @@ export enum ES_FIELD_TYPES {
// (undocumented)
HALF_FLOAT = "half_float",
// (undocumented)
HISTOGRAM = "histogram",
// (undocumented)
_ID = "_id",
// (undocumented)
_INDEX = "_index",
Expand Down Expand Up @@ -547,6 +549,8 @@ export enum KBN_FIELD_TYPES {
// (undocumented)
GEO_SHAPE = "geo_shape",
// (undocumented)
HISTOGRAM = "histogram",
// (undocumented)
IP = "ip",
// (undocumented)
MURMUR3 = "murmur3",
Expand Down
1 change: 1 addition & 0 deletions x-pack/test/functional/apps/visualize/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ export default function visualize({ loadTestFile }: FtrProviderContext) {
loadTestFile(require.resolve('./feature_controls/visualize_security'));
loadTestFile(require.resolve('./feature_controls/visualize_spaces'));
loadTestFile(require.resolve('./hybrid_visualization'));
loadTestFile(require.resolve('./precalculated_histogram'));
});
}
60 changes: 60 additions & 0 deletions x-pack/test/functional/apps/visualize/precalculated_histogram.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import expect from '@kbn/expect';
import { FtrProviderContext } from '../../ftr_provider_context';

export default function({ getService, getPageObjects }: FtrProviderContext) {
const esArchiver = getService('esArchiver');
const PageObjects = getPageObjects(['common', 'visualize', 'discover', 'visChart', 'visEditor']);
const kibanaServer = getService('kibanaServer');
const log = getService('log');

describe('pre_calculated_histogram', function() {
before(async function() {
log.debug('Starting pre_calculated_histogram before method');
await esArchiver.load('pre_calculated_histogram');
await kibanaServer.uiSettings.replace({ defaultIndex: 'test-histogram' });
});

after(function() {
return esArchiver.unload('pre_calculated_histogram');
});

const initHistogramBarChart = async () => {
await PageObjects.visualize.navigateToNewVisualization();
await PageObjects.visualize.clickVerticalBarChart();
await PageObjects.visualize.clickNewSearch('histogram-test');
await PageObjects.visChart.waitForVisualization();
};

const getFieldOptionsForAggregation = async (aggregation: string): Promise<string[]> => {
await PageObjects.visEditor.clickBucket('Y-axis', 'metrics');
await PageObjects.visEditor.selectAggregation(aggregation, 'metrics');
const fieldValues = await PageObjects.visEditor.getField();
return fieldValues;
};

it('appears correctly in discover', async function() {
await PageObjects.common.navigateToApp('discover');
const rowData = await PageObjects.discover.getDocTableIndex(1);
expect(rowData.includes('"values": [ 0.3, 1, 3, 4.2, 4.8 ]')).to.be.ok();
});

it('appears in the field options of a Percentiles aggregation', async function() {
await initHistogramBarChart();
const fieldValues: string[] = await getFieldOptionsForAggregation('Percentiles');
log.debug('Percentiles Fields = ' + fieldValues);
expect(fieldValues[0]).to.be('histogram-content');
});

it('appears in the field options of a Percentile Ranks aggregation', async function() {
const fieldValues: string[] = await getFieldOptionsForAggregation('Percentile Ranks');
log.debug('Percentile Ranks Fields = ' + fieldValues);
expect(fieldValues[0]).to.be('histogram-content');
});
});
}
Loading