Skip to content

Commit

Permalink
[ML] Data visualizer: Add icons for semantic text, sparse vector and …
Browse files Browse the repository at this point in the history
…dense vector (elastic#196069)

## Summary

Added support for `semantic_text`, `sparse_vector` and `dense_vector` in
the Data visualizer and Field Statistics.
For  [elastic#192161](elastic#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)
|

(cherry picked from commit ac5b14b)
  • Loading branch information
rbrtj committed Oct 15, 2024
1 parent abfed86 commit 4dd22bd
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
4 changes: 4 additions & 0 deletions x-pack/plugins/data_visualizer/common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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;
Expand Down

0 comments on commit 4dd22bd

Please sign in to comment.