diff --git a/.changeset/wet-pugs-exist.md b/.changeset/wet-pugs-exist.md deleted file mode 100644 index 509fb19f8d..0000000000 --- a/.changeset/wet-pugs-exist.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@backstage/plugin-catalog-backend': patch ---- - -Added optional parameter `documentType` to `DefaultCatalogCollatorFactoryOptions` which allows to override default document type `software-catalog`. For more details, see [How to customize document type in the Software Catalog index](../docs/features/search/how-to-guides.md#how-to-customize-document-type-in-the-software-catalog-index). diff --git a/docs/features/search/how-to-guides.md b/docs/features/search/how-to-guides.md index d2c8c537f2..b464168724 100644 --- a/docs/features/search/how-to-guides.md +++ b/docs/features/search/how-to-guides.md @@ -184,49 +184,6 @@ indexBuilder.addCollator({ As shown above, you can add a catalog entity filter to narrow down what catalog entities are indexed by the search engine. -## How to customize document type in the Software Catalog index - -In some cases you might want to have the ability to change the document type in which catalog entities will be indexed by catalog collator. -Such option gives a possibility to customize SearchPage results and filters depending on which document type you would like to see results for. - -You can achieve that by passing additional parameter `documentType` to the `DefaultCatalogCollatorFactory`. - -Let's say that you want to have two different document types for some entities. -Our example will cover a use case in which we want to: - -- Store entities of kind `User` or `Group` under document type `yourCustomDocumentType`, -- Store rest of entities under default document type `software-catalog` - -To achieve that you will have to remove `User` and `Group` from your previous collator `filter` and register new `DefaultCatalogCollatorFactory` with new parameter `documentType`. - -```diff -// packages/backend/src/plugins/search.ts - - indexBuilder.addCollator({ - schedule, - factory: DefaultCatalogCollatorFactory.fromConfig(env.config, { - discovery: env.discovery, - tokenManager: env.tokenManager, - filter: { -- kind: ['API', 'Component', 'Domain', 'Resource', 'System', 'Template', 'User', 'Group'], -+ kind: ['API', 'Component', 'Domain', 'Resource', 'System', 'Template'], - }, - }), - }); - -+ indexBuilder.addCollator({ -+ schedule, -+ factory: DefaultCatalogCollatorFactory.fromConfig(env.config, { -+ discovery: env.discovery, -+ tokenManager: env.tokenManager, -+ filter: { -+ kind: ['User', 'Group'], -+ }, -+ documentType: 'yourCustomDocumentType', -+ }), -+ }); -``` - ## How to customize search results highlighting styling The default highlighting styling for matched terms in search results is your diff --git a/plugins/catalog-backend/api-report.md b/plugins/catalog-backend/api-report.md index 8aae10fefb..00c13a31ea 100644 --- a/plugins/catalog-backend/api-report.md +++ b/plugins/catalog-backend/api-report.md @@ -288,7 +288,7 @@ export class DefaultCatalogCollatorFactory implements DocumentCollatorFactory { // (undocumented) getCollator(): Promise; // (undocumented) - readonly type: string; + readonly type = 'software-catalog'; // (undocumented) readonly visibilityPermission: Permission; } @@ -302,7 +302,6 @@ export type DefaultCatalogCollatorFactoryOptions = { batchSize?: number; catalogClient?: CatalogApi; entityTransformer?: CatalogCollatorEntityTransformer; - documentType?: string; }; export { DeferredEntity }; diff --git a/plugins/catalog-backend/src/search/DefaultCatalogCollatorFactory.ts b/plugins/catalog-backend/src/search/DefaultCatalogCollatorFactory.ts index d04b8d54d3..ed81d39bbb 100644 --- a/plugins/catalog-backend/src/search/DefaultCatalogCollatorFactory.ts +++ b/plugins/catalog-backend/src/search/DefaultCatalogCollatorFactory.ts @@ -42,12 +42,11 @@ export type DefaultCatalogCollatorFactoryOptions = { batchSize?: number; catalogClient?: CatalogApi; entityTransformer?: CatalogCollatorEntityTransformer; - documentType?: string; }; /** @public */ export class DefaultCatalogCollatorFactory implements DocumentCollatorFactory { - public readonly type: string; + public readonly type = 'software-catalog'; public readonly visibilityPermission: Permission = catalogEntityReadPermission; @@ -74,7 +73,6 @@ export class DefaultCatalogCollatorFactory implements DocumentCollatorFactory { catalogClient, tokenManager, entityTransformer, - documentType, } = options; this.locationTemplate = @@ -86,7 +84,6 @@ export class DefaultCatalogCollatorFactory implements DocumentCollatorFactory { this.tokenManager = tokenManager; this.entityTransformer = entityTransformer ?? defaultCatalogCollatorEntityTransformer; - this.type = documentType ?? 'software-catalog'; } async getCollator(): Promise {