From ac5b14b1254219f79dddd5da0ab9c1ff8d1ea0c1 Mon Sep 17 00:00:00 2001 From: Robert Jaszczurek <92210485+rbrtj@users.noreply.github.com> Date: Tue, 15 Oct 2024 09:52:06 +0200 Subject: [PATCH] [ML] Data visualizer: Add icons for semantic text, sparse vector and dense vector (#196069) ## Summary Added support for `semantic_text`, `sparse_vector` and `dense_vector` in the Data visualizer and Field Statistics. For [#192161](https://github.com/elastic/kibana/issues/192161) | Before | After | | ------------- | ------------- | | ![image](https://github.com/user-attachments/assets/d87de954-bae0-46d3-9934-e6e6a6424ee0) | ![image](https://github.com/user-attachments/assets/a6fced39-e227-43ea-9062-9add27aad8fd) | | ![image](https://github.com/user-attachments/assets/4c8005e3-439f-4dfc-898b-8158835d803f) | ![image](https://github.com/user-attachments/assets/a9d501cc-84f9-4394-9ffb-a6fa62269cde) | --- x-pack/plugins/data_visualizer/common/constants.ts | 4 ++++ .../application/common/util/field_types_utils.ts | 11 ++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/x-pack/plugins/data_visualizer/common/constants.ts b/x-pack/plugins/data_visualizer/common/constants.ts index ff277b9bb4785..4f552f45f61a4 100644 --- a/x-pack/plugins/data_visualizer/common/constants.ts +++ b/x-pack/plugins/data_visualizer/common/constants.ts @@ -47,6 +47,9 @@ export const SUPPORTED_FIELD_TYPES = { NESTED: 'nested', STRING: 'string', TEXT: 'text', + SEMANTIC_TEXT: 'semantic_text', + DENSE_VECTOR: 'dense_vector', + SPARSE_VECTOR: 'sparse_vector', VERSION: 'version', UNKNOWN: 'unknown', } as const; @@ -73,3 +76,4 @@ export const featureTitle = i18n.translate('xpack.dataVisualizer.title', { defaultMessage: 'Upload a file', }); export const featureId = `file_data_visualizer`; +export const SUPPORTED_FIELD_TYPES_LIST: string[] = Object.values(SUPPORTED_FIELD_TYPES); diff --git a/x-pack/plugins/data_visualizer/public/application/common/util/field_types_utils.ts b/x-pack/plugins/data_visualizer/public/application/common/util/field_types_utils.ts index 0b79cd4079f76..ad9aaf6413813 100644 --- a/x-pack/plugins/data_visualizer/public/application/common/util/field_types_utils.ts +++ b/x-pack/plugins/data_visualizer/public/application/common/util/field_types_utils.ts @@ -8,7 +8,7 @@ import type { DataViewField } from '@kbn/data-views-plugin/public'; import { KBN_FIELD_TYPES } from '@kbn/field-types'; import { getFieldType } from '@kbn/field-utils/src/utils/get_field_type'; -import { SUPPORTED_FIELD_TYPES } from '../../../../common/constants'; +import { SUPPORTED_FIELD_TYPES, SUPPORTED_FIELD_TYPES_LIST } from '../../../../common/constants'; // convert kibana types to ML Job types // this is needed because kibana types only have string and not text and keyword. @@ -26,6 +26,15 @@ export function kbnTypeToSupportedType(field: DataViewField) { } break; + case KBN_FIELD_TYPES.UNKNOWN: + const maybeFieldType = field.esTypes?.[0]; + if (maybeFieldType && SUPPORTED_FIELD_TYPES_LIST.includes(maybeFieldType)) { + type = maybeFieldType; + } else { + type = getFieldType(field); + } + break; + default: type = getFieldType(field); break;