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 16 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
@@ -0,0 +1,11 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) &gt; [IFieldType](./kibana-plugin-plugins-data-public.ifieldtype.md) &gt; [filterableType](./kibana-plugin-plugins-data-public.ifieldtype.filterabletype.md)

## IFieldType.filterableType property

<b>Signature:</b>

```typescript
filterableType?: KBN_FILTERABLE_TYPE;
```
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export interface IFieldType
| [displayName](./kibana-plugin-plugins-data-public.ifieldtype.displayname.md) | <code>string</code> | |
| [esTypes](./kibana-plugin-plugins-data-public.ifieldtype.estypes.md) | <code>string[]</code> | |
| [filterable](./kibana-plugin-plugins-data-public.ifieldtype.filterable.md) | <code>boolean</code> | |
| [filterableType](./kibana-plugin-plugins-data-public.ifieldtype.filterabletype.md) | <code>KBN_FILTERABLE_TYPE</code> | |
| [format](./kibana-plugin-plugins-data-public.ifieldtype.format.md) | <code>any</code> | |
| [lang](./kibana-plugin-plugins-data-public.ifieldtype.lang.md) | <code>string</code> | |
| [name](./kibana-plugin-plugins-data-public.ifieldtype.name.md) | <code>string</code> | |
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) &gt; [IndexPatternField](./kibana-plugin-plugins-data-public.indexpatternfield.md) &gt; [filterableType](./kibana-plugin-plugins-data-public.indexpatternfield.filterabletype.md)

## IndexPatternField.filterableType property

<b>Signature:</b>

```typescript
filterableType?: KBN_FILTERABLE_TYPE;
```
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export declare class Field implements IFieldType
| [displayName](./kibana-plugin-plugins-data-public.indexpatternfield.displayname.md) | | <code>string</code> | |
| [esTypes](./kibana-plugin-plugins-data-public.indexpatternfield.estypes.md) | | <code>string[]</code> | |
| [filterable](./kibana-plugin-plugins-data-public.indexpatternfield.filterable.md) | | <code>boolean</code> | |
| [filterableType](./kibana-plugin-plugins-data-public.indexpatternfield.filterabletype.md) | | <code>KBN_FILTERABLE_TYPE</code> | |
| [format](./kibana-plugin-plugins-data-public.indexpatternfield.format.md) | | <code>any</code> | |
| [lang](./kibana-plugin-plugins-data-public.indexpatternfield.lang.md) | | <code>string</code> | |
| [name](./kibana-plugin-plugins-data-public.indexpatternfield.name.md) | | <code>string</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
@@ -0,0 +1,11 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-plugins-data-server](./kibana-plugin-plugins-data-server.md) &gt; [IFieldType](./kibana-plugin-plugins-data-server.ifieldtype.md) &gt; [filterableType](./kibana-plugin-plugins-data-server.ifieldtype.filterabletype.md)

## IFieldType.filterableType property

<b>Signature:</b>

```typescript
filterableType?: KBN_FILTERABLE_TYPE;
```
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export interface IFieldType
| [displayName](./kibana-plugin-plugins-data-server.ifieldtype.displayname.md) | <code>string</code> | |
| [esTypes](./kibana-plugin-plugins-data-server.ifieldtype.estypes.md) | <code>string[]</code> | |
| [filterable](./kibana-plugin-plugins-data-server.ifieldtype.filterable.md) | <code>boolean</code> | |
| [filterableType](./kibana-plugin-plugins-data-server.ifieldtype.filterabletype.md) | <code>KBN_FILTERABLE_TYPE</code> | |
| [format](./kibana-plugin-plugins-data-server.ifieldtype.format.md) | <code>any</code> | |
| [lang](./kibana-plugin-plugins-data-server.ifieldtype.lang.md) | <code>string</code> | |
| [name](./kibana-plugin-plugins-data-server.ifieldtype.name.md) | <code>string</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.

3 changes: 3 additions & 0 deletions src/plugins/data/common/index_patterns/fields/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
* under the License.
*/

import { KBN_FILTERABLE_TYPE } from '../../kbn_field_types/types';

export interface IFieldSubType {
multi?: { parent: string };
nested?: { path: string };
Expand All @@ -33,6 +35,7 @@ export interface IFieldType {
esTypes?: string[];
aggregatable?: boolean;
filterable?: boolean;
filterableType?: KBN_FILTERABLE_TYPE;
searchable?: boolean;
sortable?: boolean;
visualizable?: boolean;
Expand Down
6 changes: 5 additions & 1 deletion src/plugins/data/common/index_patterns/fields/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,18 @@

import { getFilterableKbnTypeNames } from '../../kbn_field_types';
import { IFieldType } from './types';
import { KBN_FILTERABLE_TYPE } from '../..';

const filterableTypes = getFilterableKbnTypeNames();

export function isFilterable(field: IFieldType): boolean {
return (
field.name === '_id' ||
field.scripted ||
Boolean(field.searchable && filterableTypes.includes(field.type))
Boolean(
(field.searchable && filterableTypes[field.type] === KBN_FILTERABLE_TYPE.ALL) ||
ThomThomson marked this conversation as resolved.
Show resolved Hide resolved
filterableTypes[field.type] === KBN_FILTERABLE_TYPE.EXISTSONLY
)
);
}

Expand Down
4 changes: 3 additions & 1 deletion src/plugins/data/common/kbn_field_types/kbn_field_type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,20 @@
* under the License.
*/

import { KbnFieldTypeOptions, ES_FIELD_TYPES, KBN_FIELD_TYPES } from './types';
import { KbnFieldTypeOptions, ES_FIELD_TYPES, KBN_FIELD_TYPES, KBN_FILTERABLE_TYPE } from './types';

export class KbnFieldType {
public readonly name: string;
public readonly sortable: boolean;
public readonly filterable: boolean;
public readonly filterableType: KBN_FILTERABLE_TYPE;
public readonly esTypes: readonly ES_FIELD_TYPES[];

constructor(options: Partial<KbnFieldTypeOptions> = {}) {
this.name = options.name || KBN_FIELD_TYPES.UNKNOWN;
this.sortable = options.sortable || false;
this.filterable = options.filterable || false;
this.filterableType = options.filterableType || KBN_FILTERABLE_TYPE.NONE;
this.esTypes = Object.freeze((options.esTypes || []).slice());
}
}
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
9 changes: 6 additions & 3 deletions src/plugins/data/common/kbn_field_types/kbn_field_types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

import { createKbnFieldTypes } from './kbn_field_types_factory';
import { KbnFieldType } from './kbn_field_type';
import { ES_FIELD_TYPES, KBN_FIELD_TYPES } from './types';
import { ES_FIELD_TYPES, KBN_FIELD_TYPES, KBN_FILTERABLE_TYPE } from './types';

/** @private */
const registeredKbnTypes = createKbnFieldTypes();
Expand Down Expand Up @@ -58,5 +58,8 @@ export const castEsToKbnFieldTypeName = (esType: ES_FIELD_TYPES | string): KBN_F
*
* @return {Array<string>}
*/
export const getFilterableKbnTypeNames = (): string[] =>
registeredKbnTypes.filter(type => type.filterable).map(type => type.name);
export const getFilterableKbnTypeNames = (): { [key: string]: KBN_FILTERABLE_TYPE } =>
registeredKbnTypes.reduce((map: { [key: string]: KBN_FILTERABLE_TYPE }, type: KbnFieldType) => {
map[type.name] = type.filterableType;
return map;
}, {});
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,14 @@
*/

import { KbnFieldType } from './kbn_field_type';
import { ES_FIELD_TYPES, KBN_FIELD_TYPES } from './types';
import { ES_FIELD_TYPES, KBN_FIELD_TYPES, KBN_FILTERABLE_TYPE } from './types';

export const createKbnFieldTypes = (): KbnFieldType[] => [
new KbnFieldType({
name: KBN_FIELD_TYPES.STRING,
sortable: true,
filterable: true,
filterableType: KBN_FILTERABLE_TYPE.ALL,
esTypes: [
ES_FIELD_TYPES.STRING,
ES_FIELD_TYPES.TEXT,
Expand All @@ -37,6 +38,7 @@ export const createKbnFieldTypes = (): KbnFieldType[] => [
name: KBN_FIELD_TYPES.NUMBER,
sortable: true,
filterable: true,
filterableType: KBN_FILTERABLE_TYPE.ALL,
esTypes: [
ES_FIELD_TYPES.FLOAT,
ES_FIELD_TYPES.HALF_FLOAT,
Expand All @@ -53,18 +55,21 @@ export const createKbnFieldTypes = (): KbnFieldType[] => [
name: KBN_FIELD_TYPES.DATE,
sortable: true,
filterable: true,
filterableType: KBN_FILTERABLE_TYPE.ALL,
esTypes: [ES_FIELD_TYPES.DATE, ES_FIELD_TYPES.DATE_NANOS],
}),
new KbnFieldType({
name: KBN_FIELD_TYPES.IP,
sortable: true,
filterable: true,
filterableType: KBN_FILTERABLE_TYPE.ALL,
esTypes: [ES_FIELD_TYPES.IP],
}),
new KbnFieldType({
name: KBN_FIELD_TYPES.BOOLEAN,
sortable: true,
filterable: true,
filterableType: KBN_FILTERABLE_TYPE.ALL,
esTypes: [ES_FIELD_TYPES.BOOLEAN],
}),
new KbnFieldType({
Expand Down Expand Up @@ -95,6 +100,12 @@ export const createKbnFieldTypes = (): KbnFieldType[] => [
name: KBN_FIELD_TYPES._SOURCE,
esTypes: [ES_FIELD_TYPES._SOURCE],
}),
new KbnFieldType({
name: KBN_FIELD_TYPES.HISTOGRAM,
filterable: true,
filterableType: KBN_FILTERABLE_TYPE.EXISTSONLY,
esTypes: [ES_FIELD_TYPES.HISTOGRAM],
}),
new KbnFieldType({
name: KBN_FIELD_TYPES.CONFLICT,
}),
Expand Down
10 changes: 10 additions & 0 deletions src/plugins/data/common/kbn_field_types/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,17 @@
export interface KbnFieldTypeOptions {
sortable: boolean;
filterable: boolean;
filterableType: KBN_FILTERABLE_TYPE;
name: string;
esTypes: ES_FIELD_TYPES[];
}

export enum KBN_FILTERABLE_TYPE {
ALL = 'all',
NONE = 'none',
EXISTSONLY = 'existsOnly',
}

/** @public **/
export enum ES_FIELD_TYPES {
_ID = '_id',
Expand Down Expand Up @@ -59,6 +66,8 @@ export enum ES_FIELD_TYPES {
ATTACHMENT = 'attachment',
TOKEN_COUNT = 'token_count',
MURMUR3 = 'murmur3',

HISTOGRAM = 'histogram',
}

/** @public **/
Expand All @@ -77,4 +86,5 @@ export enum KBN_FIELD_TYPES {
CONFLICT = 'conflict',
OBJECT = 'object',
NESTED = 'nested',
HISTOGRAM = 'histogram',
}
11 changes: 10 additions & 1 deletion src/plugins/data/public/index_patterns/fields/field.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,13 @@ import { i18n } from '@kbn/i18n';
import { ObjDefine } from './obj_define';
import { IndexPattern } from '../index_patterns';
import { getNotifications, getFieldFormats } from '../../services';
import { IFieldType, getKbnFieldType, IFieldSubType, FieldFormat } from '../../../common';
import {
IFieldType,
getKbnFieldType,
IFieldSubType,
FieldFormat,
KBN_FILTERABLE_TYPE,
} from '../../../common';
import { shortenDottedString } from '../../../common/utils';

export type FieldSpec = Record<string, any>;
Expand All @@ -38,6 +44,7 @@ export class Field implements IFieldType {
esTypes?: string[];
aggregatable?: boolean;
filterable?: boolean;
filterableType?: KBN_FILTERABLE_TYPE;
searchable?: boolean;
sortable?: boolean;
visualizable?: boolean;
Expand Down Expand Up @@ -106,6 +113,7 @@ export class Field implements IFieldType {
const sortable = spec.name === '_score' || ((indexed || aggregatable) && type && type.sortable);
const filterable =
spec.name === '_id' || scripted || ((indexed || searchable) && type && type.filterable);
const filterableType = type?.filterableType;
const visualizable = aggregatable;

this.name = '';
Expand All @@ -129,6 +137,7 @@ export class Field implements IFieldType {
obj.comp('format', format);
obj.comp('sortable', sortable);
obj.comp('filterable', filterable);
obj.comp('filterableType', filterableType);
obj.comp('visualizable', visualizable);

// computed values
Expand Down
10 changes: 10 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 @@ -689,6 +691,10 @@ export interface IFieldType {
esTypes?: string[];
// (undocumented)
filterable?: boolean;
// Warning: (ae-forgotten-export) The symbol "KBN_FILTERABLE_TYPE" needs to be exported by the entry point index.d.ts
//
// (undocumented)
filterableType?: KBN_FILTERABLE_TYPE;
// (undocumented)
format?: any;
// (undocumented)
Expand Down Expand Up @@ -915,6 +921,8 @@ export class IndexPatternField implements IFieldType {
// (undocumented)
filterable?: boolean;
// (undocumented)
filterableType?: KBN_FILTERABLE_TYPE;
// (undocumented)
format: any;
// (undocumented)
lang?: string;
Expand Down Expand Up @@ -1126,6 +1134,8 @@ export enum KBN_FIELD_TYPES {
// (undocumented)
GEO_SHAPE = "geo_shape",
// (undocumented)
HISTOGRAM = "histogram",
// (undocumented)
IP = "ip",
// (undocumented)
MURMUR3 = "murmur3",
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
Loading