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

[ES|QL] Supports counter fields in Discover sidebar #186154

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all 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
15 changes: 13 additions & 2 deletions packages/kbn-field-types/src/kbn_field_types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,26 @@ export const castEsToKbnFieldTypeName = (esType: ES_FIELD_TYPES | string): KBN_F
export const getFilterableKbnTypeNames = (): string[] =>
registeredKbnTypes.filter((type) => type.filterable).map((type) => type.name);

function categorizeFieldType(type: string) {
// We can have 'counter_integer', 'counter_long', 'counter_double'...
if (type.includes('counter')) {
return 'counter';
}
return type;
}

export function esFieldTypeToKibanaFieldType(type: string) {
switch (type) {
const fieldTypeCategory = categorizeFieldType(type);
switch (fieldTypeCategory) {
case ES_FIELD_TYPES._INDEX:
return KBN_FIELD_TYPES.STRING;
case '_version':
return KBN_FIELD_TYPES.NUMBER;
case 'counter':
return KBN_FIELD_TYPES.COUNTER;
case 'datetime':
return KBN_FIELD_TYPES.DATE;
default:
return castEsToKbnFieldTypeName(type);
return castEsToKbnFieldTypeName(fieldTypeCategory);
}
}
1 change: 1 addition & 0 deletions packages/kbn-field-types/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,5 @@ export enum KBN_FIELD_TYPES {
NESTED = 'nested',
HISTOGRAM = 'histogram',
MISSING = 'missing',
COUNTER = 'counter',
}