Skip to content

Commit da837f2

Browse files
committed
[ML] Change to version type if detected from estypes
1 parent b352b31 commit da837f2

File tree

7 files changed

+18
-2
lines changed

7 files changed

+18
-2
lines changed

x-pack/plugins/data_visualizer/common/constants.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ export const JOB_FIELD_TYPES = {
4040
TEXT: 'text',
4141
HISTOGRAM: 'histogram',
4242
UNKNOWN: 'unknown',
43+
VERSION: 'version',
4344
} as const;
4445

4546
export const OMIT_FIELDS: string[] = ['_source', '_type', '_index', '_id', '_version', '_score'];

x-pack/plugins/data_visualizer/public/application/common/components/expanded_row/file_based_expanded_row.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ export const FileBasedDataVisualizerExpandedRow = ({ item }: { item: FileBasedFi
4141
return <IpContent config={config} />;
4242

4343
case JOB_FIELD_TYPES.KEYWORD:
44+
case JOB_FIELD_TYPES.VERSION:
4445
return <KeywordContent config={config} />;
4546

4647
case JOB_FIELD_TYPES.TEXT:

x-pack/plugins/data_visualizer/public/application/common/components/expanded_row/index_based_expanded_row.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ export const IndexBasedDataVisualizerExpandedRow = ({
7474
return <IpContent config={config} onAddFilter={onAddFilter} />;
7575

7676
case JOB_FIELD_TYPES.KEYWORD:
77+
case JOB_FIELD_TYPES.VERSION:
7778
return <KeywordContent config={config} onAddFilter={onAddFilter} />;
7879

7980
case JOB_FIELD_TYPES.TEXT:

x-pack/plugins/data_visualizer/public/application/common/components/field_data_row/action_menu/lens_utils.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@ export function getCompatibleLensDataType(type: FieldVisConfig['type']): string
201201
let lensType: string | undefined;
202202
switch (type) {
203203
case JOB_FIELD_TYPES.KEYWORD:
204+
case JOB_FIELD_TYPES.VERSION:
204205
lensType = 'string';
205206
break;
206207
case JOB_FIELD_TYPES.DATE:
@@ -234,7 +235,11 @@ function getColumnsAndLayer(
234235
if (fieldType === JOB_FIELD_TYPES.NUMBER) {
235236
return getNumberSettings(item, defaultDataView);
236237
}
237-
if (fieldType === JOB_FIELD_TYPES.IP || fieldType === JOB_FIELD_TYPES.KEYWORD) {
238+
if (
239+
fieldType === JOB_FIELD_TYPES.IP ||
240+
fieldType === JOB_FIELD_TYPES.KEYWORD ||
241+
fieldType === JOB_FIELD_TYPES.VERSION
242+
) {
238243
return getKeywordSettings(item);
239244
}
240245
if (fieldType === JOB_FIELD_TYPES.BOOLEAN) {

x-pack/plugins/data_visualizer/public/application/common/util/field_types_utils.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ export const jobTypeLabels = {
5454
[JOB_FIELD_TYPES.UNKNOWN]: i18n.translate('xpack.dataVisualizer.fieldTypeIcon.unknownTypeLabel', {
5555
defaultMessage: 'Unknown',
5656
}),
57+
[JOB_FIELD_TYPES.VERSION]: i18n.translate('xpack.dataVisualizer.fieldTypeIcon.versionTypeLabel', {
58+
defaultMessage: 'Version',
59+
}),
5760
};
5861

5962
// convert kibana types to ML Job types
@@ -62,9 +65,14 @@ export const jobTypeLabels = {
6265
export function kbnTypeToJobType(field: DataViewField) {
6366
// Return undefined if not one of the supported data visualizer field types.
6467
let type;
68+
6569
switch (field.type) {
6670
case KBN_FIELD_TYPES.STRING:
6771
type = field.aggregatable ? JOB_FIELD_TYPES.KEYWORD : JOB_FIELD_TYPES.TEXT;
72+
73+
if (field.esTypes?.includes(JOB_FIELD_TYPES.VERSION)) {
74+
type = JOB_FIELD_TYPES.VERSION;
75+
}
6876
break;
6977
case KBN_FIELD_TYPES.NUMBER:
7078
type = JOB_FIELD_TYPES.NUMBER;

x-pack/plugins/data_visualizer/public/application/index_data_visualizer/hooks/use_data_visualizer_grid_data.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,6 @@ export const useDataVisualizerGridData = (
394394

395395
nonMetricFieldsToShow.forEach((field) => {
396396
const fieldData = nonMetricFieldData.find((f) => f.fieldName === field.spec.name);
397-
398397
const nonMetricConfig: Partial<FieldVisConfig> = {
399398
...(fieldData ? fieldData : {}),
400399
fieldFormat: currentDataView.getFormatterForField(field),

x-pack/plugins/data_visualizer/public/application/index_data_visualizer/search_strategy/requests/get_fields_stats.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ export const getFieldsStats = (
3535
return fetchNumericFieldsStats(dataSearch, params, fields, options);
3636
case JOB_FIELD_TYPES.KEYWORD:
3737
case JOB_FIELD_TYPES.IP:
38+
case JOB_FIELD_TYPES.VERSION:
3839
return fetchStringFieldsStats(dataSearch, params, fields, options);
3940
case JOB_FIELD_TYPES.DATE:
4041
return fetchDateFieldsStats(dataSearch, params, fields, options);

0 commit comments

Comments
 (0)