mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-10-29 17:49:14 +00:00
fix(ui): support language for re-indexing Elasticsearch or Opensearch (#10541)
* fix(ui): support language for re-indexing Elasticsearch or Opensearch * update entity select to tree select * address comments
This commit is contained in:
parent
a51da74f86
commit
b8966a83c8
@ -11,7 +11,9 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { SearchIndexMappingLanguage } from 'generated/configuration/elasticSearchConfiguration';
|
||||
import { t } from 'i18next';
|
||||
import { map } from 'lodash';
|
||||
|
||||
export const ELASTIC_SEARCH_INDEX_ENTITIES = [
|
||||
{
|
||||
@ -82,6 +84,7 @@ export const ELASTIC_SEARCH_INITIAL_VALUES = {
|
||||
batchSize: 100,
|
||||
flushIntervalInSec: 30,
|
||||
recreateIndex: false,
|
||||
searchIndexMappingLanguage: SearchIndexMappingLanguage.En,
|
||||
};
|
||||
|
||||
export const RECREATE_INDEX_OPTIONS = [
|
||||
@ -94,3 +97,24 @@ export const RECREATE_INDEX_OPTIONS = [
|
||||
value: false,
|
||||
},
|
||||
];
|
||||
|
||||
|
||||
export const ENTITY_TREE_OPTIONS = [
|
||||
{
|
||||
title: 'All',
|
||||
value: 'all',
|
||||
key: 'all',
|
||||
children: [
|
||||
...ELASTIC_SEARCH_INDEX_ENTITIES.map(({ value, label }) => ({
|
||||
title: label,
|
||||
value: value,
|
||||
key: value,
|
||||
})),
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
export const RE_INDEX_LANG_OPTIONS = map(SearchIndexMappingLanguage, (value) => ({
|
||||
label: value,
|
||||
value,
|
||||
}));
|
||||
@ -390,6 +390,7 @@
|
||||
"kpi-name": "KPI Name",
|
||||
"kpi-title": "Key Performance Indicators (KPI)",
|
||||
"kpi-uppercase": "KPI",
|
||||
"language": "Language",
|
||||
"last": "Last",
|
||||
"last-error": "Last error",
|
||||
"last-failed-at": "Last Failed At",
|
||||
@ -573,7 +574,7 @@
|
||||
"query-plural": "Queries",
|
||||
"re-deploy": "Re Deploy",
|
||||
"re-enter-new-password": "Re-enter New Password",
|
||||
"re-index-all": "Re Index All",
|
||||
"re-index-all": "Re-Index All",
|
||||
"re-index-elasticsearch": "Re-Index Elasticsearch",
|
||||
"re-verify": "Re verify",
|
||||
"reaction-lowercase-plural": "reactions",
|
||||
|
||||
@ -390,6 +390,7 @@
|
||||
"kpi-name": "Nom des KPIs",
|
||||
"kpi-title": "Key Performance Indicators (KPI)",
|
||||
"kpi-uppercase": "KPI",
|
||||
"language": "Language",
|
||||
"last": "Last",
|
||||
"last-error": "Last error",
|
||||
"last-failed-at": "Last Failed At",
|
||||
|
||||
@ -390,6 +390,7 @@
|
||||
"kpi-name": "KPI name",
|
||||
"kpi-title": "Key Performance Indicators (KPI)",
|
||||
"kpi-uppercase": "KPI",
|
||||
"language": "Language",
|
||||
"last": "Last",
|
||||
"last-error": "Last error",
|
||||
"last-failed-at": "Last Failed At",
|
||||
|
||||
@ -11,13 +11,16 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { Checkbox, Col, Form, Input, Modal, Row, Select } from 'antd';
|
||||
import React, { useState } from 'react';
|
||||
import { Form, Input, Modal, Select, TreeSelect } from 'antd';
|
||||
import { SearchIndexMappingLanguage } from 'generated/configuration/elasticSearchConfiguration';
|
||||
import { map } from 'lodash';
|
||||
import React from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import {
|
||||
ELASTIC_SEARCH_INDEX_ENTITIES,
|
||||
ELASTIC_SEARCH_INITIAL_VALUES,
|
||||
RECREATE_INDEX_OPTIONS,
|
||||
ENTITY_TREE_OPTIONS,
|
||||
RE_INDEX_LANG_OPTIONS
|
||||
} from '../../constants/elasticsearch.constant';
|
||||
import { CreateEventPublisherJob } from '../../generated/api/createEventPublisherJob';
|
||||
|
||||
@ -35,9 +38,8 @@ const ReIndexAllModal = ({
|
||||
confirmLoading,
|
||||
}: ReIndexAllModalInterface) => {
|
||||
const { t } = useTranslation();
|
||||
const [entities, setEntities] = useState<string[]>(
|
||||
ELASTIC_SEARCH_INITIAL_VALUES.entities
|
||||
);
|
||||
|
||||
|
||||
|
||||
return (
|
||||
<Modal
|
||||
@ -56,11 +58,11 @@ const ReIndexAllModal = ({
|
||||
onCancel={onCancel}>
|
||||
<Form
|
||||
id="re-index-form"
|
||||
initialValues={ELASTIC_SEARCH_INITIAL_VALUES}
|
||||
layout="vertical"
|
||||
name="elastic-search-re-index"
|
||||
onFinish={onSave}>
|
||||
<Form.Item
|
||||
initialValue
|
||||
label={t('label.recreate-index-plural')}
|
||||
name="recreateIndex">
|
||||
<Select
|
||||
@ -68,24 +70,14 @@ const ReIndexAllModal = ({
|
||||
options={RECREATE_INDEX_OPTIONS}
|
||||
/>
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
initialValue={entities}
|
||||
label={t('label.entity-plural')}
|
||||
name="entities">
|
||||
<Checkbox.Group
|
||||
onChange={(values) => setEntities(values as string[])}>
|
||||
<Row gutter={[16, 16]}>
|
||||
{ELASTIC_SEARCH_INDEX_ENTITIES.map((option) => (
|
||||
<Col key={option.value} span={8}>
|
||||
<Checkbox value={option.value}>{option.label}</Checkbox>
|
||||
</Col>
|
||||
))}
|
||||
</Row>
|
||||
</Checkbox.Group>
|
||||
<Form.Item label={t('label.entity-plural')} name="entities">
|
||||
<TreeSelect
|
||||
treeCheckable
|
||||
treeDefaultExpandAll
|
||||
treeData={ENTITY_TREE_OPTIONS}
|
||||
/>
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
initialValue={ELASTIC_SEARCH_INITIAL_VALUES.flushIntervalInSec}
|
||||
label={t('label.flush-interval-secs')}
|
||||
name="flushIntervalInSec">
|
||||
<Input
|
||||
@ -96,10 +88,7 @@ const ReIndexAllModal = ({
|
||||
/>
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
initialValue={ELASTIC_SEARCH_INITIAL_VALUES.batchSize}
|
||||
label={`${t('label.batch-size')}:`}
|
||||
name="batchSize">
|
||||
<Form.Item label={`${t('label.batch-size')}:`} name="batchSize">
|
||||
<Input
|
||||
data-testid="batch-size"
|
||||
placeholder={t('label.enter-entity', {
|
||||
@ -107,6 +96,11 @@ const ReIndexAllModal = ({
|
||||
})}
|
||||
/>
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
label={`${t('label.language')}:`}
|
||||
name="searchIndexMappingLanguage">
|
||||
<Select options={RE_INDEX_LANG_OPTIONS} />
|
||||
</Form.Item>
|
||||
</Form>
|
||||
</Modal>
|
||||
);
|
||||
|
||||
@ -11,6 +11,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { AxiosResponse } from 'axios';
|
||||
import axiosClient from '.';
|
||||
import { CreateEventPublisherJob } from '../generated/api/createEventPublisherJob';
|
||||
import {
|
||||
@ -27,23 +28,16 @@ export const getAllReIndexStatus = async (mode: RunMode) => {
|
||||
return res.data;
|
||||
};
|
||||
|
||||
export const reIndexByPublisher = async ({
|
||||
runMode,
|
||||
entities = ['all'],
|
||||
recreateIndex = true,
|
||||
batchSize,
|
||||
flushIntervalInSec,
|
||||
}: CreateEventPublisherJob) => {
|
||||
export const reIndexByPublisher = async (data: CreateEventPublisherJob) => {
|
||||
const payload = {
|
||||
...data,
|
||||
publisherType: PublisherType.ElasticSearch,
|
||||
runMode,
|
||||
recreateIndex,
|
||||
entities,
|
||||
batchSize,
|
||||
flushIntervalInSec,
|
||||
};
|
||||
|
||||
const res = await axiosClient.post('/indexResource/reindex', payload);
|
||||
const res = await axiosClient.post<
|
||||
CreateEventPublisherJob,
|
||||
AxiosResponse<EventPublisherJob>
|
||||
>('/indexResource/reindex', payload);
|
||||
|
||||
return res.data;
|
||||
};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user