diff --git a/plugins/search-backend-module-pg/src/PgSearchEngine/PgSearchEngine.ts b/plugins/search-backend-module-pg/src/PgSearchEngine/PgSearchEngine.ts index bf98c58de9..d8128f8568 100644 --- a/plugins/search-backend-module-pg/src/PgSearchEngine/PgSearchEngine.ts +++ b/plugins/search-backend-module-pg/src/PgSearchEngine/PgSearchEngine.ts @@ -15,6 +15,7 @@ */ import { PluginDatabaseManager } from '@backstage/backend-common'; import { SearchEngine } from '@backstage/plugin-search-backend-node'; +import { MissingIndexError } from '@backstage/plugin-search-backend-node'; import { SearchQuery, IndexableResultSet, @@ -92,6 +93,12 @@ export class PgSearchEngine implements SearchEngine { this.databaseStore.query(tx, pgQuery), ); + if (!rows.length) { + throw new MissingIndexError( + `Missing index for ${pgQuery.types}. This means there are no documents to search through.`, + ); + } + // We requested one result more than the page size to know whether there is // another page. const { page } = decodePageCursor(query.pageCursor);