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