diff --git a/models/interfaces.ts b/models/interfaces.ts index 062dd49e8..73260bb3b 100644 --- a/models/interfaces.ts +++ b/models/interfaces.ts @@ -7,7 +7,6 @@ import { long } from "@opensearch-project/opensearch/api/types"; import { ActionType } from "../public/pages/VisualCreatePolicy/utils/constants"; -import { IndicesUpdateMode } from "../public/utils/constants"; export interface ManagedIndexMetaData { index: string; @@ -490,6 +489,7 @@ export interface Rollup { schema_version: number; source_index: string; target_index: string; + target_index_settings: Map | null; roles: string[]; } diff --git a/public/pages/CreateRollup/components/JobNameAndIndices/JobNameAndIndices.tsx b/public/pages/CreateRollup/components/JobNameAndIndices/JobNameAndIndices.tsx index b00024394..d2c2b6637 100644 --- a/public/pages/CreateRollup/components/JobNameAndIndices/JobNameAndIndices.tsx +++ b/public/pages/CreateRollup/components/JobNameAndIndices/JobNameAndIndices.tsx @@ -5,15 +5,17 @@ import React, { Component } from "react"; import { EuiFlexGrid, EuiSpacer, EuiFlexItem, EuiText, EuiFlexGroup, EuiHorizontalRule, EuiPanel, EuiTitle } from "@elastic/eui"; -import { ContentPanel, ContentPanelActions } from "../../../../components/ContentPanel"; +import { ContentPanelActions } from "../../../../components/ContentPanel"; import { ModalConsumer } from "../../../../components/Modal"; import { IndexItem } from "../../../../../models/interfaces"; +import { getOrderedJson } from "../../../../../utils/helper"; interface JobNameAndIndicesProps { rollupId: string; description: string; sourceIndex: { label: string; value?: IndexItem }[]; targetIndex: { label: string; value?: IndexItem }[]; + targetIndexSettings: Pick | null; onChangeStep: (step: number) => void; } @@ -23,7 +25,7 @@ export default class JobNameAndIndices extends Component } render() { - const { rollupId, description, onChangeStep, sourceIndex, targetIndex } = this.props; + const { rollupId, description, onChangeStep, sourceIndex, targetIndex, targetIndexSettings } = this.props; return ( @@ -72,6 +74,14 @@ export default class JobNameAndIndices extends Component
{targetIndex[0].label}
+ {targetIndexSettings && ( + + +
Target index Settings
+
{JSON.stringify(getOrderedJson(targetIndexSettings || {}), null, 2)}
+
+
+ )}
Description
diff --git a/public/pages/CreateRollup/components/RollupIndices/RollupIndices.tsx b/public/pages/CreateRollup/components/RollupIndices/RollupIndices.tsx index 795480c36..085d3ca27 100644 --- a/public/pages/CreateRollup/components/RollupIndices/RollupIndices.tsx +++ b/public/pages/CreateRollup/components/RollupIndices/RollupIndices.tsx @@ -22,6 +22,9 @@ import { IndexItem } from "../../../../../models/interfaces"; import IndexService from "../../../../services/IndexService"; import { CoreServicesContext } from "../../../../components/core_services"; import { wildcardOption } from "../../../../utils/helpers"; +import AdvancedSettings from "../../../../components/AdvancedSettings"; +import flat from "flat"; +import { INDEX_SETTINGS_URL } from "../../../../utils/constants"; interface RollupIndicesProps { indexService: IndexService; @@ -29,8 +32,11 @@ interface RollupIndicesProps { sourceIndexError: string; targetIndex: { label: string; value?: IndexItem }[]; targetIndexError: string; + targetIndexSettings: Pick | null; + targetIndexSettingsError: string; onChangeSourceIndex: (options: EuiComboBoxOptionOption[]) => void; onChangeTargetIndex: (options: EuiComboBoxOptionOption[]) => void; + onChangeTargetIndexSettings: (settings: Pick | null) => void; hasAggregation: boolean; } @@ -124,8 +130,11 @@ export default class RollupIndices extends Component + + + {"Optional. The target index settings will be apply only if target index will be created during the rollup."} + { + + Learn more + + } +
+ } + > + { + if (Object.keys(val).length === 0) { + onChangeTargetIndexSettings(null); + } else { + onChangeTargetIndexSettings(val); + } + }} + accordionProps={{ + initialIsOpen: false, + id: "accordionForCreateRollupTargetIndexSettings", + buttonContent:

Target index settings

, + }} + editorProps={{ + disabled: false, + width: "100%", + formatValue: flat, + }} + rowProps={{ + fullWidth: true, + label: "Specify advanced index settings", + helpText: ( + <> +

+ Specify a comma-delimited list of settings.{" "} + + View index settings + +

+

+ All the settings will be handled in flat structure.{" "} + + Learn more + +

+ + ), + }} + /> +
); } diff --git a/public/pages/CreateRollup/containers/CreateRollup/CreateRollup.tsx b/public/pages/CreateRollup/containers/CreateRollup/CreateRollup.tsx index 04b58d5cf..b0c9e907d 100644 --- a/public/pages/CreateRollup/containers/CreateRollup/CreateRollup.tsx +++ b/public/pages/CreateRollup/containers/CreateRollup/CreateRollup.tsx @@ -3,8 +3,8 @@ * SPDX-License-Identifier: Apache-2.0 */ -import React, { ChangeEvent, Component, useContext } from "react"; -import { EuiSpacer, EuiTitle, EuiFlexGroup, EuiFlexItem, EuiComboBoxOptionOption, EuiText } from "@elastic/eui"; +import React, { ChangeEvent, Component } from "react"; +import { EuiSpacer, EuiFlexGroup, EuiFlexItem, EuiComboBoxOptionOption, EuiText } from "@elastic/eui"; import { RouteComponentProps } from "react-router-dom"; import { RollupService } from "../../../../services"; import ConfigureRollup from "../../components/ConfigureRollup"; @@ -12,7 +12,7 @@ import RollupIndices from "../../components/RollupIndices"; import CreateRollupSteps from "../../components/CreateRollupSteps"; import IndexService from "../../../../services/IndexService"; import { IndexItem } from "../../../../../models/interfaces"; -import { DataSourceMenuContext, DataSourceMenuProperties } from "../../../../services/DataSourceMenuContext"; +import { DataSourceMenuProperties } from "../../../../services/DataSourceMenuContext"; interface CreateRollupProps extends RouteComponentProps, DataSourceMenuProperties { rollupService: RollupService; @@ -27,10 +27,13 @@ interface CreateRollupProps extends RouteComponentProps, DataSourceMenuPropertie sourceIndexError: string; targetIndex: { label: string; value?: IndexItem }[]; targetIndexError: string; + targetIndexSettings: Pick | null; + targetIndexSettingsError: string; onChangeName: (e: ChangeEvent) => void; onChangeDescription: (value: ChangeEvent) => void; onChangeSourceIndex: (options: EuiComboBoxOptionOption[]) => void; onChangeTargetIndex: (options: EuiComboBoxOptionOption[]) => void; + onChangeTargetIndexSettings: (settings: Pick | null) => void; currentStep: number; hasAggregation: boolean; useNewUX: boolean; diff --git a/public/pages/CreateRollup/containers/CreateRollupForm/CreateRollupForm.tsx b/public/pages/CreateRollup/containers/CreateRollupForm/CreateRollupForm.tsx index 0d90bf29f..00cfa18fd 100644 --- a/public/pages/CreateRollup/containers/CreateRollupForm/CreateRollupForm.tsx +++ b/public/pages/CreateRollup/containers/CreateRollupForm/CreateRollupForm.tsx @@ -5,7 +5,7 @@ import React, { ChangeEvent, Component, useContext } from "react"; import { EuiSmallButton, EuiSmallButtonEmpty, EuiComboBoxOptionOption, EuiFlexGroup, EuiFlexItem } from "@elastic/eui"; -import { RouteComponentProps, useHistory } from "react-router-dom"; +import { RouteComponentProps } from "react-router-dom"; import moment from "moment"; import { RollupService } from "../../../../services"; import { BREADCRUMBS, ROUTES } from "../../../../utils/constants"; @@ -24,7 +24,6 @@ import { CoreServicesContext } from "../../../../components/core_services"; import { DataSourceMenuContext, DataSourceMenuProperties, - DataSourceMenuReadOnlyContext, DataSourceMenuReadOnlyProperties, } from "../../../../services/DataSourceMenuContext"; import { useUpdateUrlWithDataSourceProperties } from "../../../../components/MDSEnabledComponent"; @@ -53,6 +52,8 @@ interface CreateRollupFormState { sourceIndexError: string; targetIndex: { label: string; value?: IndexItem }[]; targetIndexError: string; + targetIndexSettings: Pick | null; + targetIndexSettingsError: string; mappings: any; allMappings: FieldItem[][]; @@ -115,6 +116,8 @@ export class CreateRollupForm extends Component | null): void => { + let newJSON = this.state.rollupJSON; + newJSON.rollup.target_index_settings = settings; + this.setState({ targetIndexSettings: settings, rollupJSON: newJSON }); + }; + onChangeIntervalType = (intervalType: string): void => { this.setState({ intervalType, timeunit: "h" }); }; @@ -573,6 +582,8 @@ export class CreateRollupForm extends Component spec renders the component 1`] = ` +
+
+
+
+ +
+
+
+
+
+
+
+ +
+
+
+

+ Specify a comma-delimited list of settings. + + + View index settings + EuiIconMock + + (opens in a new tab or window) + + +

+

+ All the settings will be handled in flat structure. + + + Learn more + EuiIconMock + + (opens in a new tab or window) + + +

+
+ +
+ +
+