From 189ab3bd3752bfa7102e7b9582bc311add44623e Mon Sep 17 00:00:00 2001 From: "opensearch-trigger-bot[bot]" <98922864+opensearch-trigger-bot[bot]@users.noreply.github.com> Date: Wed, 25 Oct 2023 13:54:47 -0700 Subject: [PATCH] updated field mappings service; abort detector creation when mapping fails (#752) (#768) Signed-off-by: Amardeepsingh Siglani (cherry picked from commit 141965087c68ae711b40d81a7f23d3165a992f9c) Co-authored-by: Amardeepsingh Siglani --- .../CreateDetector/containers/CreateDetector.tsx | 16 +++++++++++++++- public/services/FieldMappingService.ts | 4 ++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/public/pages/CreateDetector/containers/CreateDetector.tsx b/public/pages/CreateDetector/containers/CreateDetector.tsx index 0e1c42d99..d5a90ddaa 100644 --- a/public/pages/CreateDetector/containers/CreateDetector.tsx +++ b/public/pages/CreateDetector/containers/CreateDetector.tsx @@ -30,6 +30,7 @@ import { NotificationsStart } from 'opensearch-dashboards/public'; import { getPlugins } from '../../../utils/helpers'; import { Detector, DetectorCreationStep } from '../../../../types'; import { DataStore } from '../../../store/DataStore'; +import { errorNotificationToast } from '../../../utils/helpers'; interface CreateDetectorProps extends RouteComponentProps { isEdit: boolean; @@ -107,7 +108,7 @@ export default class CreateDetector extends Component { + onCreateClick = async () => { const { creatingDetector, detector, fieldMappings } = this.state; if (creatingDetector) { return; @@ -121,6 +122,19 @@ export default class CreateDetector extends Component { + if (mapping.ruleFieldName === mapping.indexFieldName) { + return; + } + alias_mappings.properties[mapping.ruleFieldName] = { type: 'alias', path: mapping.indexFieldName,