MINOR - Metadata Actions - New Actions (#16037)

* MINOR - Metadata Actions - New Actions

* Add actions

* Add actions

* Add actions

* Add actions

* Add actions

* Add actions

* Add support for chart search in UI

* Refactor searchEntity function in AlertsUtil.tsx and getSearchIndexEntityTypeMapping function in SearchClassBase.ts

* add domain

* add domain

* format

* Update setSourceAsValue parameter in searchEntity function

* add missing fields in the advanced search field selection for all the assets

---------

Co-authored-by: Aniket Katkar <aniketkatkar97@gmail.com>
This commit is contained in:
Pere Miquel Brull 2024-04-30 07:11:03 +02:00 committed by GitHub
parent 6055955f4e
commit a5e062cf30
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
20 changed files with 739 additions and 100 deletions

View File

@ -24,6 +24,8 @@ from metadata.generated.schema.entity.data.searchIndex import SearchIndex
from metadata.generated.schema.entity.data.storedProcedure import StoredProcedure
from metadata.generated.schema.entity.data.table import Table
from metadata.generated.schema.entity.data.topic import Topic
from metadata.generated.schema.entity.domains.dataProduct import DataProduct
from metadata.generated.schema.entity.domains.domain import Domain
from metadata.generated.schema.entity.services.dashboardService import DashboardService
from metadata.generated.schema.entity.services.databaseService import DatabaseService
from metadata.generated.schema.entity.services.messagingService import MessagingService
@ -96,6 +98,9 @@ ENTITY_REFERENCE_CLASS_MAP = {
# User Entities
"user": User,
"team": Team,
# Domain
"domain": Domain,
"dataProduct": DataProduct,
}
ENTITY_REFERENCE_TYPE_MAP = {

View File

@ -0,0 +1,44 @@
{
"$id": "https://open-metadata.org/schema/entity/applications/configuration/external/automator/addDescriptionAction.json",
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "AddDescriptionAction",
"description": "Apply Tags to the selected assets.",
"type": "object",
"definitions": {
"addDescriptionActionType": {
"description": "Add Description Action Type.",
"type": "string",
"enum": ["AddDescriptionAction"],
"default": "AddDescriptionAction"
}
},
"properties": {
"type": {
"title": "Application Type",
"description": "Application Type",
"$ref": "#/definitions/addDescriptionActionType",
"default": "AddDescriptionAction"
},
"description": {
"description": "Description to apply",
"type": "string"
},
"applyToChildren": {
"title": "Apply to Children",
"description": "Apply the description to the children of the selected assets that match the criteria. E.g., columns, tasks, topic fields,...",
"type": "array",
"items": {
"$ref": "../../../../../type/basic.json#/definitions/entityName"
},
"default": null
},
"overwriteMetadata": {
"title": "Overwrite Metadata",
"description": "Update the description even if they are already defined in the asset. By default, we'll only add the descriptions to assets without the description set.",
"type": "boolean",
"default": false
}
},
"required": ["type", "description"],
"additionalProperties": false
}

View File

@ -0,0 +1,35 @@
{
"$id": "https://open-metadata.org/schema/entity/applications/configuration/external/automator/addDomainAction.json",
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "AddDomainAction",
"description": "Add an owner to the selected assets.",
"type": "object",
"definitions": {
"addDomainActionType": {
"description": "Add Owner Action Type.",
"type": "string",
"enum": ["AddDomainAction"],
"default": "AddDomainAction"
}
},
"properties": {
"type": {
"title": "Application Type",
"description": "Application Type",
"$ref": "#/definitions/addDomainActionType",
"default": "AddDomainAction"
},
"domain": {
"description": "Domain to apply",
"$ref": "../../../../../type/entityReference.json"
},
"overwriteMetadata": {
"title": "Overwrite Metadata",
"description": "Update the domain even if it is defined in the asset. By default, we will only apply the domain to assets without domain.",
"type": "boolean",
"default": false
}
},
"required": ["type", "domain"],
"additionalProperties": false
}

View File

@ -0,0 +1,35 @@
{
"$id": "https://open-metadata.org/schema/entity/applications/configuration/external/automator/addOwnerAction.json",
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "AddOwnerAction",
"description": "Add an owner to the selected assets.",
"type": "object",
"definitions": {
"addOwnerActionType": {
"description": "Add Owner Action Type.",
"type": "string",
"enum": ["AddOwnerAction"],
"default": "AddOwnerAction"
}
},
"properties": {
"type": {
"title": "Application Type",
"description": "Application Type",
"$ref": "#/definitions/addOwnerActionType",
"default": "AddOwnerAction"
},
"owner": {
"description": "Owner to apply",
"$ref": "../../../../../type/entityReference.json"
},
"overwriteMetadata": {
"title": "Overwrite Metadata",
"description": "Update the owner even if it is defined in the asset. By default, we will only apply the owner to assets without owner.",
"type": "boolean",
"default": false
}
},
"required": ["type", "owner"],
"additionalProperties": false
}

View File

@ -0,0 +1,47 @@
{
"$id": "https://open-metadata.org/schema/entity/applications/configuration/external/automator/addTagsAction.json",
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "AddTagsAction",
"description": "Apply Tags to the selected assets.",
"type": "object",
"definitions": {
"addTagsActionType": {
"description": "Add Tags action type.",
"type": "string",
"enum": ["AddTagsAction"],
"default": "AddTagsAction"
}
},
"properties": {
"type": {
"title": "Application Type",
"description": "Application Type",
"$ref": "#/definitions/addTagsActionType",
"default": "AddTagsAction"
},
"tags": {
"description": "Tags to apply",
"type": "array",
"items": {
"$ref": "../../../../../type/tagLabel.json"
}
},
"applyToChildren": {
"title": "Apply to Children",
"description": "Apply tags to the children of the selected assets that match the criteria. E.g., columns, tasks, topic fields,...",
"type": "array",
"items": {
"$ref": "../../../../../type/basic.json#/definitions/entityName"
},
"default": null
},
"overwriteMetadata": {
"title": "Overwrite Metadata",
"description": "Update tags even if they are already defined in the asset. By default, incoming tags are merged with the existing ones.",
"type": "boolean",
"default": false
}
},
"required": ["type", "tags"],
"additionalProperties": false
}

View File

@ -0,0 +1,35 @@
{
"$id": "https://open-metadata.org/schema/entity/applications/configuration/external/automator/addTierAction.json",
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "AddTierAction",
"description": "Add an owner to the selected assets.",
"type": "object",
"definitions": {
"addTierActionType": {
"description": "Add Tier Action Type.",
"type": "string",
"enum": ["AddTierAction"],
"default": "AddTierAction"
}
},
"properties": {
"type": {
"title": "Application Type",
"description": "Application Type",
"$ref": "#/definitions/addTierActionType",
"default": "AddTierAction"
},
"tier": {
"description": "tier to apply",
"$ref": "../../../../../type/tagLabel.json"
},
"overwriteMetadata": {
"title": "Overwrite Metadata",
"description": "Update the tier even if it is defined in the asset. By default, we will only apply the tier to assets without tier.",
"type": "boolean",
"default": false
}
},
"required": ["type", "tier"],
"additionalProperties": false
}

View File

@ -19,15 +19,9 @@
"$ref": "#/definitions/lineagePropagationActionType",
"default": "LineagePropagationAction"
},
"overwriteDescriptions": {
"title": "Overwrite Descriptions",
"description": "Update descriptions via lineage even if they are already defined in the asset. By default, descriptions are only updated if they are not already defined in the asset.",
"type": "boolean",
"default": false
},
"overwriteTags": {
"title": "Overwrite Tags",
"description": "Update tags via lineage disregarding the existing tags in the asset. By default, we merge the existing tags with the ones coming from the lineage.",
"overwriteMetadata": {
"title": "Overwrite Metadata",
"description": "Update descriptions and tags via lineage even if they are already defined in the asset. By default, descriptions are only updated if they are not already defined in the asset, and incoming tags are merged with the existing ones.",
"type": "boolean",
"default": false
}

View File

@ -0,0 +1,34 @@
{
"$id": "https://open-metadata.org/schema/entity/applications/configuration/external/automator/removeDescriptionAction.json",
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "RemoveDescriptionAction",
"description": "Remove Owner Action Type",
"type": "object",
"definitions": {
"removeDescriptionActionType": {
"description": "Remove Description Action Type",
"type": "string",
"enum": ["RemoveDescriptionAction"],
"default": "RemoveDescriptionAction"
}
},
"properties": {
"type": {
"title": "Application Type",
"description": "Application Type",
"$ref": "#/definitions/removeDescriptionActionType",
"default": "RemoveDescriptionAction"
},
"applyToChildren": {
"title": "Apply to Children",
"description": "Remove descriptions from all children of the selected assets. E.g., columns, tasks, topic fields,...",
"type": "array",
"items": {
"$ref": "../../../../../type/basic.json#/definitions/entityName"
},
"default": null
}
},
"required": ["type"],
"additionalProperties": false
}

View File

@ -0,0 +1,25 @@
{
"$id": "https://open-metadata.org/schema/entity/applications/configuration/external/automator/removeDomainAction.json",
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "RemoveDomainAction",
"description": "Remove Owner Action Type",
"type": "object",
"definitions": {
"removeDomainActionType": {
"description": "Remove Domain Action Type",
"type": "string",
"enum": ["RemoveDomainAction"],
"default": "RemoveDomainAction"
}
},
"properties": {
"type": {
"title": "Application Type",
"description": "Application Type",
"$ref": "#/definitions/removeDomainActionType",
"default": "RemoveDomainAction"
}
},
"required": ["type"],
"additionalProperties": false
}

View File

@ -0,0 +1,25 @@
{
"$id": "https://open-metadata.org/schema/entity/applications/configuration/external/automator/removeOwnerAction.json",
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "RemoveOwnerAction",
"description": "Remove Owner Action Type",
"type": "object",
"definitions": {
"removeOwnerActionType": {
"description": "Remove Owner Action Type",
"type": "string",
"enum": ["RemoveOwnerAction"],
"default": "RemoveOwnerAction"
}
},
"properties": {
"type": {
"title": "Application Type",
"description": "Application Type",
"$ref": "#/definitions/removeOwnerActionType",
"default": "RemoveOwnerAction"
}
},
"required": ["type"],
"additionalProperties": false
}

View File

@ -0,0 +1,41 @@
{
"$id": "https://open-metadata.org/schema/entity/applications/configuration/external/automator/removeTagsAction.json",
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "RemoveTagsAction",
"description": "Remove Tags Action Type",
"type": "object",
"definitions": {
"removeTagsActionType": {
"description": "Remove Tags Action Type.",
"type": "string",
"enum": ["RemoveTagsAction"],
"default": "RemoveTagsAction"
}
},
"properties": {
"type": {
"title": "Application Type",
"description": "Application Type",
"$ref": "#/definitions/removeTagsActionType",
"default": "AddTagsAction"
},
"tags": {
"description": "Tags to remove",
"type": "array",
"items": {
"$ref": "../../../../../type/tagLabel.json"
}
},
"applyToChildren": {
"title": "Apply to Children",
"description": "Remove tags from all the children of the selected assets. E.g., columns, tasks, topic fields,...",
"type": "array",
"items": {
"$ref": "../../../../../type/basic.json#/definitions/entityName"
},
"default": null
}
},
"required": ["type", "tags"],
"additionalProperties": false
}

View File

@ -0,0 +1,25 @@
{
"$id": "https://open-metadata.org/schema/entity/applications/configuration/external/automator/removeTierAction.json",
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "RemoveTierAction",
"description": "Remove Owner Action Type",
"type": "object",
"definitions": {
"removeTierActionType": {
"description": "Remove Tier Action Type",
"type": "string",
"enum": ["RemoveTierAction"],
"default": "RemoveTierAction"
}
},
"properties": {
"type": {
"title": "Application Type",
"description": "Application Type",
"$ref": "#/definitions/removeTierActionType",
"default": "RemoveTierAction"
}
},
"required": ["type"],
"additionalProperties": false
}

View File

@ -1,61 +0,0 @@
{
"$id": "https://open-metadata.org/schema/entity/applications/configuration/external/automator/ruleBasedTaggingAction.json",
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "RuleBasedTaggingAction",
"description": "Apply Tags based on rules",
"type": "object",
"definitions": {
"ruleBasedTaggingActionType": {
"description": "Rule Based Tagging action type.",
"type": "string",
"enum": ["RuleBasedTaggingAction"],
"default": "RuleBasedTaggingAction"
},
"tagMode": {
"description": "Tag Mode",
"type": "string",
"enum": ["NameContains", "Regex"],
"default": "NameContains"
},
"tagRule": {
"description": "Tag Rule",
"type": "object",
"properties": {
"mode": {
"description": "Tag Mode",
"$ref": "#/definitions/tagMode"
},
"expression": {
"description": "Expression to apply",
"type": "string"
},
"tags": {
"description": "Tags to apply",
"type": "array",
"items": {
"$ref": "../../../../../type/tagLabel.json"
}
}
},
"required": ["mode", "expression", "tags"],
"additionalProperties": false
}
},
"properties": {
"type": {
"title": "Application Type",
"description": "Application Type",
"$ref": "#/definitions/ruleBasedTaggingActionType",
"default": "RuleBasedTaggingAction"
},
"rules": {
"description": "Rules to apply",
"type": "array",
"items": {
"$ref": "#/definitions/tagRule"
}
}
},
"required": ["type", "rules"],
"additionalProperties": false
}

View File

@ -28,6 +28,47 @@
"type": "string"
}
}
},
"action": {
"description": "Action to take on those entities. E.g., propagate description through lineage, auto tagging, etc.",
"oneOf": [
{
"$ref": "automator/addTagsAction.json"
},
{
"$ref": "automator/removeTagsAction.json"
},
{
"$ref": "automator/addDomainAction.json"
},
{
"$ref": "automator/removeDomainAction.json"
},
{
"$ref": "automator/addDescriptionAction.json"
},
{
"$ref": "automator/removeDescriptionAction.json"
},
{
"$ref": "automator/addTierAction.json"
},
{
"$ref": "automator/removeTierAction.json"
},
{
"$ref": "automator/addOwnerAction.json"
},
{
"$ref": "automator/removeOwnerAction.json"
},
{
"$ref": "automator/lineagePropagationAction.json"
},
{
"$ref": "automator/mlTaggingAction.json"
}
]
}
},
"properties": {
@ -41,21 +82,14 @@
"description": "Entities selected to run the automation.",
"$ref": "#/definitions/resource"
},
"action": {
"actions": {
"description": "Action to take on those entities. E.g., propagate description through lineage, auto tagging, etc.",
"oneOf": [
{
"$ref": "automator/lineagePropagationAction.json"
},
{
"$ref": "automator/mlTaggingAction.json"
},
{
"$ref": "automator/ruleBasedTaggingAction.json"
}
]
"type": "array",
"items": {
"$ref": "#/definitions/action"
}
}
},
"required": ["type", "resources", "action"],
"required": ["type", "resources", "actions"],
"additionalProperties": false
}

View File

@ -35,6 +35,15 @@ export enum AdvancedFields {
}
export enum EntityFields {
SERVICE_TYPE = 'serviceType',
DATA_MODEL_TYPE = 'dataModelType',
DOMAIN = 'domain.displayName.keyword',
DATA_MODEL = 'dataModels.displayName.keyword',
CONTAINER_COLUMN = 'dataModel.columns.name.keyword',
PROJECT = 'project.keyword',
SCHEMA_FIELD = 'messageSchema.schemaFields.name',
FEATURE = 'mlFeatures.name',
FIELD = 'fields.name.keyword',
OWNER = 'displayName.keyword',
TAG = 'tags.tagFQN',
TIER = 'tier.tagFQN',

View File

@ -16,6 +16,7 @@ export enum SearchIndex {
DATA_ASSET = 'dataAsset',
TABLE = 'table_search_index',
TOPIC = 'topic_search_index',
CHART = 'chart_search_index',
DASHBOARD = 'dashboard_search_index',
PIPELINE = 'pipeline_search_index',
USER = 'user_search_index',

View File

@ -15,6 +15,7 @@ import { SearchedDataProps } from '../components/SearchedData/SearchedData.inter
import { DataInsightIndex } from '../enums/DataInsight.enum';
import { SearchIndex } from '../enums/search.enum';
import { Tag } from '../generated/entity/classification/tag';
import { Chart } from '../generated/entity/data/chart';
import { Container } from '../generated/entity/data/container';
import { Dashboard } from '../generated/entity/data/dashboard';
import { DashboardDataModel } from '../generated/entity/data/dashboardDataModel';
@ -90,6 +91,8 @@ export interface UserSearchSource extends SearchSourceBase, User {} // extends E
export interface TeamSearchSource extends SearchSourceBase, Team {} // extends EntityInterface
export interface ContainerSearchSource extends SearchSourceBase, Container {} // extends EntityInterface
export interface ChartSearchSource extends SearchSourceBase, Chart {} // extends EntityInterface
export interface DataBaseSchemaSearchSource
extends SearchSourceBase,
DatabaseSchema {} // extends EntityInterface
@ -187,6 +190,7 @@ export type SearchIndexSearchSourceMapping = {
[SearchIndex.ALL]: TableSearchSource;
[SearchIndex.DATA_ASSET]: TableSearchSource;
[SearchIndex.TABLE]: TableSearchSource;
[SearchIndex.CHART]: ChartSearchSource;
[SearchIndex.MLMODEL]: MlmodelSearchSource;
[SearchIndex.PIPELINE]: PipelineSearchSource;
[SearchIndex.DASHBOARD]: DashboardSearchSource;

View File

@ -110,6 +110,180 @@ class AdvancedSearchClassBase {
},
};
/**
* Fields specific to pipelines
*/
pipelineQueryBuilderFields: Fields = {
'tasks.displayName.keyword': {
label: t('label.task'),
type: 'select',
mainWidgetProps: this.mainWidgetProps,
fieldSettings: {
asyncFetch: this.autocomplete({
searchIndex: SearchIndex.PIPELINE,
entityField: EntityFields.TASK,
}),
useAsyncSearch: true,
},
},
};
/**
* Fields specific to topics
*/
topicQueryBuilderFields: Fields = {
'messageSchema.schemaFields.name': {
label: t('label.schema-field'),
type: 'select',
mainWidgetProps: this.mainWidgetProps,
fieldSettings: {
asyncFetch: this.autocomplete({
searchIndex: SearchIndex.TOPIC,
entityField: EntityFields.SCHEMA_FIELD,
}),
useAsyncSearch: true,
},
},
};
/**
* Fields specific to dashboard
*/
dashboardQueryBuilderFields: Fields = {
'dataModels.displayName.keyword': {
label: t('label.data-model'),
type: 'select',
mainWidgetProps: this.mainWidgetProps,
fieldSettings: {
asyncFetch: this.autocomplete({
searchIndex: SearchIndex.DASHBOARD,
entityField: EntityFields.DATA_MODEL,
}),
useAsyncSearch: true,
},
},
'charts.displayName.keyword': {
label: t('label.chart'),
type: 'select',
mainWidgetProps: this.mainWidgetProps,
fieldSettings: {
asyncFetch: this.autocomplete({
searchIndex: SearchIndex.DASHBOARD,
entityField: EntityFields.CHART,
}),
useAsyncSearch: true,
},
},
'project.keyword': {
label: t('label.project'),
type: 'select',
mainWidgetProps: this.mainWidgetProps,
fieldSettings: {
asyncFetch: this.autocomplete({
searchIndex: SearchIndex.DASHBOARD,
entityField: EntityFields.PROJECT,
}),
useAsyncSearch: true,
},
},
};
/**
* Fields specific to ML models
*/
mlModelQueryBuilderFields: Fields = {
'mlFeatures.name': {
label: t('label.feature'),
type: 'select',
mainWidgetProps: this.mainWidgetProps,
fieldSettings: {
asyncFetch: this.autocomplete({
searchIndex: SearchIndex.MLMODEL,
entityField: EntityFields.FEATURE,
}),
useAsyncSearch: true,
},
},
};
/**
* Fields specific to containers
*/
containerQueryBuilderFields: Fields = {
'dataModel.columns.name.keyword': {
label: t('label.column'),
type: 'select',
mainWidgetProps: this.mainWidgetProps,
fieldSettings: {
asyncFetch: this.autocomplete({
searchIndex: SearchIndex.CONTAINER,
entityField: EntityFields.CONTAINER_COLUMN,
}),
useAsyncSearch: true,
},
},
};
/**
* Fields specific to search indexes
*/
searchIndexQueryBuilderFields: Fields = {
'fields.name.keyword': {
label: t('label.field'),
type: 'select',
mainWidgetProps: this.mainWidgetProps,
fieldSettings: {
asyncFetch: this.autocomplete({
searchIndex: SearchIndex.SEARCH_INDEX,
entityField: EntityFields.FIELD,
}),
useAsyncSearch: true,
},
},
};
/**
* Fields specific to dashboard data models
*/
dataModelQueryBuilderFields: Fields = {
dataModelType: {
label: t('label.data-model-type'),
type: 'select',
mainWidgetProps: this.mainWidgetProps,
fieldSettings: {
asyncFetch: this.autocomplete({
searchIndex: SearchIndex.DASHBOARD_DATA_MODEL,
entityField: EntityFields.DATA_MODEL_TYPE,
}),
useAsyncSearch: true,
},
},
'columns.name.keyword': {
label: t('label.column'),
type: 'select',
mainWidgetProps: this.mainWidgetProps,
fieldSettings: {
asyncFetch: this.autocomplete({
searchIndex: SearchIndex.DASHBOARD_DATA_MODEL,
entityField: EntityFields.COLUMN,
}),
useAsyncSearch: true,
},
},
'project.keyword': {
label: t('label.project'),
type: 'select',
mainWidgetProps: this.mainWidgetProps,
fieldSettings: {
asyncFetch: this.autocomplete({
searchIndex: SearchIndex.DASHBOARD_DATA_MODEL,
entityField: EntityFields.PROJECT,
}),
useAsyncSearch: true,
},
},
};
/**
* Overriding default configurations.
* Basic attributes that fields inherit from.
@ -206,19 +380,16 @@ class AdvancedSearchClassBase {
};
};
/**
* Common fields that exit for all searchable entities
*/
public getQueryBuilderFields = ({
entitySearchIndex = [SearchIndex.TABLE],
tierOptions = Promise.resolve([]),
shouldAddServiceField = true,
}: {
public getCommonConfig(args: {
entitySearchIndex?: Array<SearchIndex>;
tierOptions?: Promise<AsyncFetchListValues>;
shouldAddServiceField?: boolean;
}) => {
const commonQueryBuilderFields: Fields = {
}): Fields {
const {
entitySearchIndex = [SearchIndex.TABLE],
tierOptions = Promise.resolve([]),
} = args;
return {
deleted: {
label: t('label.deleted'),
type: 'boolean',
@ -239,6 +410,34 @@ class AdvancedSearchClassBase {
},
},
'domain.displayName.keyword': {
label: t('label.domain'),
type: 'select',
mainWidgetProps: this.mainWidgetProps,
fieldSettings: {
asyncFetch: this.autocomplete({
searchIndex: entitySearchIndex,
entityField: EntityFields.DOMAIN,
}),
useAsyncSearch: true,
},
},
serviceType: {
label: t('label.service-type'),
type: 'select',
mainWidgetProps: this.mainWidgetProps,
fieldSettings: {
asyncFetch: this.autocomplete({
searchIndex: entitySearchIndex,
entityField: EntityFields.SERVICE_TYPE,
}),
useAsyncSearch: true,
},
},
'tags.tagFQN': {
label: t('label.tag-plural'),
type: 'select',
@ -282,7 +481,68 @@ class AdvancedSearchClassBase {
},
},
};
}
/**
* Get entity specific fields for the query builder
*/
public getEntitySpecificQueryBuilderFields(
entitySearchIndex = [SearchIndex.TABLE]
): Fields {
let configs: Fields = {};
entitySearchIndex.forEach((index) => {
switch (index) {
case SearchIndex.TABLE:
configs = { ...configs, ...this.tableQueryBuilderFields };
break;
case SearchIndex.PIPELINE:
configs = { ...configs, ...this.pipelineQueryBuilderFields };
break;
case SearchIndex.DASHBOARD:
configs = { ...configs, ...this.dashboardQueryBuilderFields };
break;
case SearchIndex.TOPIC:
configs = { ...configs, ...this.topicQueryBuilderFields };
break;
case SearchIndex.MLMODEL:
configs = { ...configs, ...this.mlModelQueryBuilderFields };
break;
case SearchIndex.CONTAINER:
configs = { ...configs, ...this.containerQueryBuilderFields };
break;
case SearchIndex.SEARCH_INDEX:
configs = { ...configs, ...this.searchIndexQueryBuilderFields };
break;
case SearchIndex.DASHBOARD_DATA_MODEL:
configs = { ...configs, ...this.dataModelQueryBuilderFields };
break;
}
});
return configs;
}
/**
* Common fields that exit for all searchable entities
*/
public getQueryBuilderFields = ({
entitySearchIndex = [SearchIndex.TABLE],
tierOptions = Promise.resolve([]),
shouldAddServiceField = true,
}: {
entitySearchIndex?: Array<SearchIndex>;
tierOptions?: Promise<AsyncFetchListValues>;
shouldAddServiceField?: boolean;
}) => {
const serviceQueryBuilderFields: Fields = {
'service.displayName.keyword': {
label: t('label.service'),
@ -299,11 +559,9 @@ class AdvancedSearchClassBase {
};
return {
...commonQueryBuilderFields,
...this.getCommonConfig({ entitySearchIndex, tierOptions }),
...(shouldAddServiceField ? serviceQueryBuilderFields : {}),
...(entitySearchIndex.includes(SearchIndex.TABLE)
? this.tableQueryBuilderFields
: {}),
...this.getEntitySpecificQueryBuilderFields(entitySearchIndex),
};
};

View File

@ -155,16 +155,18 @@ export const getDisplayNameForEntities = (entity: string) => {
export const EDIT_LINK_PATH = `/settings/notifications/edit-alert`;
export const EDIT_DATA_INSIGHT_REPORT_PATH = `/settings/notifications/edit-data-insight-report`;
const searchEntity = async ({
export const searchEntity = async ({
searchText,
searchIndex,
filters,
showDisplayNameAsLabel = true,
setSourceAsValue = false,
}: {
searchText: string;
searchIndex: SearchIndex | SearchIndex[];
filters?: string;
showDisplayNameAsLabel?: boolean;
setSourceAsValue?: boolean;
}) => {
try {
const response = await searchData(
@ -176,6 +178,8 @@ const searchEntity = async ({
'',
searchIndex
);
const searchIndexEntityTypeMapping =
searchClassBase.getSearchIndexEntityTypeMapping();
return uniqBy(
response.data.hits.hits.map((d) => {
@ -187,9 +191,16 @@ const searchEntity = async ({
? getEntityName(d._source)
: d._source.fullyQualifiedName ?? '';
const value = setSourceAsValue
? JSON.stringify({
...d._source,
type: searchIndexEntityTypeMapping[d._index],
})
: d._source.fullyQualifiedName ?? '';
return {
label: displayName,
value: d._source.fullyQualifiedName ?? '',
value,
};
}),
'label'

View File

@ -70,6 +70,7 @@ class SearchClassBase {
return {
[EntityType.ALL]: SearchIndex.ALL,
[EntityType.TABLE]: SearchIndex.TABLE,
[EntityType.CHART]: SearchIndex.CHART,
[EntityType.PIPELINE]: SearchIndex.PIPELINE,
[EntityType.DASHBOARD]: SearchIndex.DASHBOARD,
[EntityType.MLMODEL]: SearchIndex.MLMODEL,
@ -100,6 +101,43 @@ class SearchClassBase {
};
}
public getSearchIndexEntityTypeMapping(): Partial<
Record<SearchIndex, EntityType>
> {
return {
[SearchIndex.ALL]: EntityType.ALL,
[SearchIndex.TABLE]: EntityType.TABLE,
[SearchIndex.CHART]: EntityType.CHART,
[SearchIndex.PIPELINE]: EntityType.PIPELINE,
[SearchIndex.DASHBOARD]: EntityType.DASHBOARD,
[SearchIndex.MLMODEL]: EntityType.MLMODEL,
[SearchIndex.TOPIC]: EntityType.TOPIC,
[SearchIndex.CONTAINER]: EntityType.CONTAINER,
[SearchIndex.TAG]: EntityType.TAG,
[SearchIndex.GLOSSARY_TERM]: EntityType.GLOSSARY_TERM,
[SearchIndex.STORED_PROCEDURE]: EntityType.STORED_PROCEDURE,
[SearchIndex.DASHBOARD_DATA_MODEL]: EntityType.DASHBOARD_DATA_MODEL,
[SearchIndex.SEARCH_INDEX]: EntityType.SEARCH_INDEX,
[SearchIndex.DATABASE_SERVICE]: EntityType.DATABASE_SERVICE,
[SearchIndex.MESSAGING_SERVICE]: EntityType.MESSAGING_SERVICE,
[SearchIndex.DASHBOARD_SERVICE]: EntityType.DASHBOARD_SERVICE,
[SearchIndex.PIPELINE_SERVICE]: EntityType.PIPELINE_SERVICE,
[SearchIndex.ML_MODEL_SERVICE]: EntityType.MLMODEL_SERVICE,
[SearchIndex.STORAGE_SERVICE]: EntityType.STORAGE_SERVICE,
[SearchIndex.SEARCH_SERVICE]: EntityType.SEARCH_SERVICE,
[SearchIndex.DOMAIN]: EntityType.DOMAIN,
[SearchIndex.DATA_PRODUCT]: EntityType.DATA_PRODUCT,
[SearchIndex.DATABASE]: EntityType.DATABASE,
[SearchIndex.DATABASE_SCHEMA]: EntityType.DATABASE_SCHEMA,
[SearchIndex.USER]: EntityType.USER,
[SearchIndex.TEAM]: EntityType.TEAM,
[SearchIndex.TEST_CASE]: EntityType.TEST_CASE,
[SearchIndex.TEST_SUITE]: EntityType.TEST_SUITE,
[SearchIndex.GLOSSARY]: EntityType.GLOSSARY,
[SearchIndex.INGESTION_PIPELINE]: EntityType.INGESTION_PIPELINE,
};
}
public getGlobalSearchOptions() {
return [
{ value: '', label: i18n.t('label.all') },