diff --git a/plugins/catalog-backend/src/search/util.ts b/plugins/catalog-backend/src/search/util.ts index 47a5570899..7e7ce7064e 100644 --- a/plugins/catalog-backend/src/search/util.ts +++ b/plugins/catalog-backend/src/search/util.ts @@ -25,15 +25,13 @@ function isGroupEntity(entity: Entity): entity is UserEntity { } export function getDocumentText(entity: Entity): string { - let documentText = entity.metadata.description || ''; + const documentTexts: string[] = []; + documentTexts.push(entity.metadata.description || ''); + if (isUserEntity(entity) || isGroupEntity(entity)) { - if (entity.spec?.profile?.displayName && documentText) { - // combine displayName and description - const displayName = entity.spec.profile.displayName; - documentText = displayName.concat(' : ', documentText); - } else { - documentText = entity.spec?.profile?.displayName || documentText; + if (entity.spec?.profile?.displayName) { + documentTexts.push(entity.spec.profile.displayName); } } - return documentText; + return documentTexts.join(' : '); }