Skip to content

Commit

Permalink
[8.15] [Index management] Fix passthrough field bug (#193246) (#194187)
Browse files Browse the repository at this point in the history
# Backport

This will backport the following commits from `main` to `8.15`:
- [[Index management] Fix passthrough field bug
(#193246)](#193246)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Ignacio
Rivas","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-09-26T16:26:51Z","message":"[Index
management] Fix passthrough field bug
(#193246)","sha":"99160b6f9963c3ba9b3065ae89c9042a44b3c3d9","branchLabelMapping":{"^v9.0.0$":"main","^v8.16.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Feature:Index
Management","Team:Kibana
Management","release_note:skip","v9.0.0","backport:prev-major","v8.16.0"],"title":"[Index
management] Fix passthrough field
bug","number":193246,"url":"https://github.com/elastic/kibana/pull/193246","mergeCommit":{"message":"[Index
management] Fix passthrough field bug
(#193246)","sha":"99160b6f9963c3ba9b3065ae89c9042a44b3c3d9"}},"sourceBranch":"main","suggestedTargetBranches":["8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/193246","number":193246,"mergeCommit":{"message":"[Index
management] Fix passthrough field bug
(#193246)","sha":"99160b6f9963c3ba9b3065ae89c9042a44b3c3d9"}},{"branch":"8.x","label":"v8.16.0","branchLabelMappingKey":"^v8.16.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Ignacio Rivas <[email protected]>
  • Loading branch information
kibanamachine and sabarasaba authored Sep 26, 2024
1 parent 9e0bc9f commit badcb6e
Show file tree
Hide file tree
Showing 6 changed files with 79 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -79,7 +79,9 @@ export const TypeParameter = ({
)}
</EuiLink>
</EuiText>
) : null
) : (
<EuiSpacer size="m" />
)
}
>
<EuiComboBox
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import { OtherType } from './other_type';
import { NestedType } from './nested_type';
import { JoinType } from './join_type';
import { HistogramType } from './histogram_type';
import { PassthroughType } from './passthrough_type';
import { ConstantKeywordType } from './constant_keyword_type';
import { RankFeatureType } from './rank_feature_type';
import { WildcardType } from './wildcard_type';
Expand Down Expand Up @@ -62,6 +63,7 @@ const typeToParametersFormMap: { [key in DataType]?: ComponentType<any> } = {
nested: NestedType,
join: JoinType,
histogram: HistogramType,
passthrough: PassthroughType,
constant_keyword: ConstantKeywordType,
rank_feature: RankFeatureType,
wildcard: WildcardType,
Expand Down
Original file line number Diff line number Diff line change
@@ -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 (
<BasicParametersSection>
<UseField path="priority" config={getFieldConfig('priority')} component={Field} />
<UseField
path="dynamic"
config={getFieldConfig('dynamic_passthrough')}
component={CheckBoxField}
/>
</BasicParametersSection>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,12 @@ export const TYPE_DEFINITION: { [key in DataType]: DataTypeDefinition } = {
</p>
),
},
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',
Expand Down Expand Up @@ -998,7 +1004,6 @@ export const TYPE_DEFINITION: { [key in DataType]: DataTypeDefinition } = {
),
},
};

export const MAIN_TYPES: MainType[] = [
'alias',
'binary',
Expand All @@ -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: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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: '',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export type MainType =
| 'percolator'
| 'rank_feature'
| 'rank_features'
| 'passthrough'
| 'shape'
| 'search_as_you_type'
| 'sparse_vector'
Expand Down Expand Up @@ -158,6 +159,8 @@ export type ParameterName =
| 'points_only'
| 'path'
| 'dims'
| 'priority'
| 'dynamic_passthrough'
| 'inference_id'
| 'reference_field'
| 'depth_limit'
Expand Down

0 comments on commit badcb6e

Please sign in to comment.