From abfca5bf9ee95c8c95251de3bce366d3daf22108 Mon Sep 17 00:00:00 2001 From: Oliver Sand Date: Thu, 5 Aug 2021 09:36:49 +0200 Subject: [PATCH] Move setup instructions from readme to microsite Signed-off-by: Oliver Sand --- docs/features/search/search-engines.md | 31 +++++++++++++++++++++- plugins/search-backend-module-pg/README.md | 18 +++---------- 2 files changed, 33 insertions(+), 16 deletions(-) diff --git a/docs/features/search/search-engines.md b/docs/features/search/search-engines.md index ec04dadede..a2e4831824 100644 --- a/docs/features/search/search-engines.md +++ b/docs/features/search/search-engines.md @@ -16,7 +16,7 @@ QueryTranslator interface. This modification can be done without touching provided search engines by using the exposed setter to set the modified query translator into the instance. -``` +```typescript const searchEngine = new LunrSearchEngine({ logger }); searchEngine.setTranslator(new MyNewAndBetterQueryTranslator()); ``` @@ -34,6 +34,35 @@ const searchEngine = new LunrSearchEngine({ logger }); const indexBuilder = new IndexBuilder({ logger, searchEngine }); ``` +## Postgres + +The Postgres based search engine only requires that postgres being configured as +the database engine for Backstage. Therefore it targets setups that want to +avoid maintaining another external service like elastic search. The search +provides decent results and performs well with ten thousands of indexed +documents. The connection to postgres is established via the database manager +also used by other plugins. + +> **Important**: The search plugin requires at least Postgres 11! + +To use the `PgSearchEngine`, make sure that you have a Postgres database +configured and make the following changes to your backend: + +1. Add a dependency on `@backstage/plugin-search-backend-module-pg` to your + backend's `package.json`. +2. Initialize the search engine. It is recommended to initialize it with a + fallback to the lunr search engine if you are running Backstage for + development locally with SQLite: + +```typescript +// In packages/backend/src/plugins/search.ts + +// Initialize a connection to a search engine. +const searchEngine = (await PgSearchEngine.supported(database)) + ? await PgSearchEngine.from({ database }) + : new LunrSearchEngine({ logger }); +``` + ## ElasticSearch Backstage supports ElasticSearch search engine connections, indexing and diff --git a/plugins/search-backend-module-pg/README.md b/plugins/search-backend-module-pg/README.md index ae069ad848..fb9dbccc4a 100644 --- a/plugins/search-backend-module-pg/README.md +++ b/plugins/search-backend-module-pg/README.md @@ -10,19 +10,7 @@ other plugins. > **Important**: The search plugin requires at least Postgres 11! -## Setup +## Getting started -To use the `SearchEngine`, make sure that you have a Postgres database -configured and make the following changes to your backend: - -1. Add a dependency on `@backstage/plugin-search-backend-module-pg` to your backend's `package.json`. -2. Initialize the search engine. It is recommended to initialize it with a fallback to the lunr search engine if you are running Backstage for development locally with SQLite: - -```typescript -// In packages/backend/src/plugins/search.ts - -// Initialize a connection to a search engine. -const searchEngine = (await PgSearchEngine.supported(database)) - ? await PgSearchEngine.from({ database }) - : new LunrSearchEngine({ logger }); -``` +See [Backstage documentation](https://backstage.io/docs/features/search/search-engines#postgres) +for details on how to setup Postgres based search for your Backstage instance.