diff --git a/docs/features/search/collators.md b/docs/features/search/collators.md index 834a14437a..d87258f65b 100644 --- a/docs/features/search/collators.md +++ b/docs/features/search/collators.md @@ -134,6 +134,38 @@ search: timeout: { minutes: 3 } ``` +### Filtering through the catalog collator + +The TechDocs collator by default filters through catalog entities where the annotation `metadata.annotations.backstage.io/techdocs-ref` exists. If you wish to further filter out entities, there are two ways to do so through the `techDocsCollatorEntityFilterExtensionPoint`. + +```typescript +export const exampleCustomCatalogFiltering = createBackendModule({ + pluginId: 'search', + moduleId: 'search-techdocs-collator-entity-filter', + register(reg) { + reg.registerInit({ + deps: { + customCollatorFilter: techDocsCollatorEntityFilterExtensionPoint, + }, + async init({ customCollatorFilter }) { + /* filtering by catalog params */ + customCollatorFilter.setCustomCatalogApiFilters([ + { kind: ['API', 'Component', ...] }, + { metadata: ['...more filters'] }, + ]); + + /* filtering by a custom function */ + customCollatorFilter.setEntityFilterFunction((entities: Entity[]) => + entities.filter( + entity => entity.metadata?.annotations?.abc === 'xyz', + ), + ); + }, + }); + }, +}); +``` + ## Community Collators Here are some of the known Search Collators available in from the Backstage Community: