[Search] add how to guide for indexing TechDocs documents (#7625)

* add how to guide for indexing techdocs documents

Signed-off-by: Emma Indal <emma.indahl@gmail.com>

* add step of how to add techdocs to search type filter

Signed-off-by: Emma Indal <emma.indahl@gmail.com>
This commit is contained in:
Emma Indal
2021-10-15 11:46:34 +02:00
committed by GitHub
parent 35b7a0bbd5
commit 157843e5aa
2 changed files with 56 additions and 4 deletions
+4 -4
View File
@@ -113,10 +113,10 @@ search engines.
## Plugins Integrated with Search
| Plugin | Support Status |
| -------- | -------------- |
| Catalog | ✅ |
| TechDocs | ✅ |
| Plugin | Support Status |
| -------------------------------------------------------------- | -------------- |
| Catalog | ✅ |
| [TechDocs](./how-to-guides.md#how-to-index-techdocs-documents) | ✅ |
[Reach out to us](#get-involved) if you want to chat about support for more
plugins integrated to search.
+52
View File
@@ -44,3 +44,55 @@ const app = createApp({
],
});
```
## How to index TechDocs documents
The techdocs-plugin has supported integrations to Search, meaning that it
provides a default collator ready to be used.
The purpose of this how-to guide is to walk you through how to register the
[DefaultTechDocsCollator](https://github.com/backstage/backstage/blob/master/plugins/techdocs-backend/src/search/DefaultTechDocsCollator.ts)
in your App in two steps, so that you can get TechDocs documents indexed.
If you have been through the
[getting started guide](https://backstage.io/docs/features/search/getting-started)
already, you should have the `packages/backend/src/plugins/search.ts` file
available. If you have that, you can jump to the first step of this guide, if
not - start by go through the getting started guide.
1. Import the DefaultTechDocsCollator from `@backstage/plugin-techdocs-backend`.
```typescript
import { DefaultTechDocsCollator } from '@backstage/plugin-techdocs-backend';
```
2. Register the DefaultTechDocsCollator with the IndexBuilder.
```typescript
indexBuilder.addCollator({
defaultRefreshIntervalSeconds: 600,
collator: DefaultTechDocsCollator.fromConfig(config, {
discovery,
logger,
}),
});
```
You should now have your TechDocs documents indexed to your search engine of
choice!
If you want your users to be able to filter down to the techdocs type when
searching. You can update your `SearchPage.tsx` file in
`packages/app/src/components/search` by adding `techdocs` to the list of values
of the `SearchType` component.
```tsx
<Paper className={classes.filters}>
<SearchType
values={['techdocs', 'software-catalog']}
name="type"
defaultValue="software-catalog"
/>
...
</Paper>
```