From badcb6e3d924d25820f7b9d408f116767e355669 Mon Sep 17 00:00:00 2001 From: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> Date: Fri, 27 Sep 2024 04:04:16 +1000 Subject: [PATCH] [8.15] [Index management] Fix passthrough field bug (#193246) (#194187) # Backport This will backport the following commits from `main` to `8.15`: - [[Index management] Fix passthrough field bug (#193246)](https://github.com/elastic/kibana/pull/193246) ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) Co-authored-by: Ignacio Rivas --- .../field_parameters/type_parameter.tsx | 6 ++-- .../fields/field_types/index.ts | 2 ++ .../fields/field_types/passthrough_type.tsx | 25 ++++++++++++++ .../constants/data_types_definition.tsx | 19 +++++++---- .../constants/parameters_definition.tsx | 33 +++++++++++++++++++ .../mappings_editor/types/document_fields.ts | 3 ++ 6 files changed, 79 insertions(+), 9 deletions(-) create mode 100644 x-pack/plugins/index_management/public/application/components/mappings_editor/components/document_fields/fields/field_types/passthrough_type.tsx diff --git a/x-pack/plugins/index_management/public/application/components/mappings_editor/components/document_fields/field_parameters/type_parameter.tsx b/x-pack/plugins/index_management/public/application/components/mappings_editor/components/document_fields/field_parameters/type_parameter.tsx index 0016707967396..ec467f113c46d 100644 --- a/x-pack/plugins/index_management/public/application/components/mappings_editor/components/document_fields/field_parameters/type_parameter.tsx +++ b/x-pack/plugins/index_management/public/application/components/mappings_editor/components/document_fields/field_parameters/type_parameter.tsx @@ -6,7 +6,7 @@ */ import React, { useMemo } from 'react'; -import { EuiFormRow, EuiComboBox, EuiText, EuiLink } from '@elastic/eui'; +import { EuiFormRow, EuiComboBox, EuiText, EuiLink, EuiSpacer } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import { documentationService } from '../../../../../services/documentation'; @@ -79,7 +79,9 @@ export const TypeParameter = ({ )} - ) : null + ) : ( + + ) } > } = { nested: NestedType, join: JoinType, histogram: HistogramType, + passthrough: PassthroughType, constant_keyword: ConstantKeywordType, rank_feature: RankFeatureType, wildcard: WildcardType, diff --git a/x-pack/plugins/index_management/public/application/components/mappings_editor/components/document_fields/fields/field_types/passthrough_type.tsx b/x-pack/plugins/index_management/public/application/components/mappings_editor/components/document_fields/fields/field_types/passthrough_type.tsx new file mode 100644 index 0000000000000..0e8515d3c6f60 --- /dev/null +++ b/x-pack/plugins/index_management/public/application/components/mappings_editor/components/document_fields/fields/field_types/passthrough_type.tsx @@ -0,0 +1,25 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import React from 'react'; + +import { UseField, Field, CheckBoxField } from '../../../../shared_imports'; +import { getFieldConfig } from '../../../../lib'; +import { BasicParametersSection } from '../edit_field'; + +export const PassthroughType = () => { + return ( + + + + + ); +}; diff --git a/x-pack/plugins/index_management/public/application/components/mappings_editor/constants/data_types_definition.tsx b/x-pack/plugins/index_management/public/application/components/mappings_editor/constants/data_types_definition.tsx index 1c39bac607f46..130433a86426c 100644 --- a/x-pack/plugins/index_management/public/application/components/mappings_editor/constants/data_types_definition.tsx +++ b/x-pack/plugins/index_management/public/application/components/mappings_editor/constants/data_types_definition.tsx @@ -567,6 +567,12 @@ export const TYPE_DEFINITION: { [key in DataType]: DataTypeDefinition } = {

), }, + passthrough: { + label: i18n.translate('xpack.idxMgmt.mappingsEditor.dataType.passthroughDescription', { + defaultMessage: 'Passthrough', + }), + value: 'passthrough', + }, dense_vector: { label: i18n.translate('xpack.idxMgmt.mappingsEditor.dataType.denseVectorDescription', { defaultMessage: 'Dense vector', @@ -998,7 +1004,6 @@ export const TYPE_DEFINITION: { [key in DataType]: DataTypeDefinition } = { ), }, }; - export const MAIN_TYPES: MainType[] = [ 'alias', 'binary', @@ -1011,28 +1016,28 @@ export const MAIN_TYPES: MainType[] = [ 'flattened', 'geo_point', 'geo_shape', + 'histogram', 'ip', 'join', 'keyword', + 'match_only_text', 'nested', 'numeric', - 'match_only_text', 'object', + 'other', 'percolator', + 'point', 'range', 'rank_feature', 'rank_features', 'search_as_you_type', - 'shape', 'semantic_text', + 'shape', 'sparse_vector', 'text', 'token_count', - 'histogram', - 'wildcard', - 'point', 'version', - 'other', + 'wildcard', ]; export const MAIN_DATA_TYPE_DEFINITION: { diff --git a/x-pack/plugins/index_management/public/application/components/mappings_editor/constants/parameters_definition.tsx b/x-pack/plugins/index_management/public/application/components/mappings_editor/constants/parameters_definition.tsx index 0be09876b63f2..7e10c5d5deaa7 100644 --- a/x-pack/plugins/index_management/public/application/components/mappings_editor/constants/parameters_definition.tsx +++ b/x-pack/plugins/index_management/public/application/components/mappings_editor/constants/parameters_definition.tsx @@ -1067,6 +1067,39 @@ export const PARAMETERS_DEFINITION: { [key in ParameterName]: ParameterDefinitio }, schema: t.string, }, + priority: { + fieldConfig: { + defaultValue: '', + type: FIELD_TYPES.NUMBER, + label: i18n.translate('xpack.idxMgmt.mappingsEditor.priorityFieldLabel', { + defaultMessage: 'Priority', + }), + formatters: [toInt], + validations: [ + { + validator: emptyField( + i18n.translate( + 'xpack.idxMgmt.mappingsEditor.parameters.validations.priorityIsRequiredErrorMessage', + { + defaultMessage: 'Specify a priority.', + } + ) + ), + }, + ], + }, + schema: t.string, + }, + dynamic_passthrough: { + fieldConfig: { + defaultValue: false, + type: FIELD_TYPES.CHECKBOX, + label: i18n.translate('xpack.idxMgmt.mappingsEditor.dynamicFieldLabel', { + defaultMessage: 'Dynamic', + }), + }, + schema: t.boolean, + }, reference_field: { fieldConfig: { defaultValue: '', diff --git a/x-pack/plugins/index_management/public/application/components/mappings_editor/types/document_fields.ts b/x-pack/plugins/index_management/public/application/components/mappings_editor/types/document_fields.ts index 7ff156f6817f1..c98b5f38fdb4b 100644 --- a/x-pack/plugins/index_management/public/application/components/mappings_editor/types/document_fields.ts +++ b/x-pack/plugins/index_management/public/application/components/mappings_editor/types/document_fields.ts @@ -58,6 +58,7 @@ export type MainType = | 'percolator' | 'rank_feature' | 'rank_features' + | 'passthrough' | 'shape' | 'search_as_you_type' | 'sparse_vector' @@ -158,6 +159,8 @@ export type ParameterName = | 'points_only' | 'path' | 'dims' + | 'priority' + | 'dynamic_passthrough' | 'inference_id' | 'reference_field' | 'depth_limit'