diff --git a/.changeset/metal-windows-share.md b/.changeset/metal-windows-share.md index 4fc568986a..0c5e6bb26e 100644 --- a/.changeset/metal-windows-share.md +++ b/.changeset/metal-windows-share.md @@ -2,4 +2,6 @@ '@backstage/plugin-search-backend-module-pg': patch --- +**DEPRECATED**: `PgSearchEngine` static `from` has been depracated and will be removed in a future release. Use static `fromConfig` method to instantiate. + Added support for highlighting matched terms in search result data diff --git a/plugins/search-backend-module-pg/api-report.md b/plugins/search-backend-module-pg/api-report.md index 23e261ca4d..0d03a83d34 100644 --- a/plugins/search-backend-module-pg/api-report.md +++ b/plugins/search-backend-module-pg/api-report.md @@ -44,7 +44,7 @@ export class DatabaseDocumentStore implements DatabaseStore { // (undocumented) query( tx: Knex.Transaction, - { types, pgTerm, fields, offset, limit, options }: PgSearchQuery, + searchQuery: PgSearchQuery, ): Promise; // (undocumented) static supported(knex: Knex): Promise; @@ -81,17 +81,18 @@ export interface DatabaseStore { // // @public (undocumented) export class PgSearchEngine implements SearchEngine { - // Warning: (ae-forgotten-export) The symbol "PgSearchHighlightOptions" needs to be exported by the entry point index.d.ts - constructor( - databaseStore: DatabaseStore, - highlightOptions?: PgSearchHighlightOptions, - ); - // (undocumented) + constructor(databaseStore: DatabaseStore, config: Config); + // @deprecated (undocumented) static from(options: { database: PluginDatabaseManager; config: Config; }): Promise; // (undocumented) + static fromConfig({ + config, + database, + }: PgSearchOptions): Promise; + // (undocumented) getIndexer(type: string): Promise; // (undocumented) query(query: SearchQuery): Promise; @@ -101,12 +102,10 @@ export class PgSearchEngine implements SearchEngine { ): void; // (undocumented) static supported(database: PluginDatabaseManager): Promise; - // Warning: (ae-forgotten-export) The symbol "PgSearchHighlightConfig" needs to be exported by the entry point index.d.ts - // // (undocumented) translator( query: SearchQuery, - options: PgSearchHighlightConfig, + options: PgSearchHighlightOptions, ): ConcretePgSearchQuery; } @@ -132,6 +131,25 @@ export type PgSearchEngineIndexerOptions = { databaseStore: DatabaseStore; }; +// @public +export type PgSearchHighlightOptions = { + useHighlight?: boolean; + maxWords?: number; + minWords?: number; + shortWord?: number; + highlightAll?: boolean; + maxFragments?: number; + fragmentDelimiter?: string; + preTag: string; + postTag: string; +}; + +// @public +export type PgSearchOptions = { + config: Config; + database: PluginDatabaseManager; +}; + // Warning: (ae-missing-release-tag) "PgSearchQuery" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // // @public (undocumented) @@ -143,7 +161,7 @@ export interface PgSearchQuery { // (undocumented) offset: number; // (undocumented) - options: PgSearchHighlightConfig; + options: PgSearchHighlightOptions; // (undocumented) pgTerm?: string; // (undocumented) diff --git a/plugins/search-backend-module-pg/src/index.ts b/plugins/search-backend-module-pg/src/index.ts index 4cb54f9676..86184d1e4e 100644 --- a/plugins/search-backend-module-pg/src/index.ts +++ b/plugins/search-backend-module-pg/src/index.ts @@ -22,4 +22,4 @@ export * from './database'; export * from './PgSearchEngine'; -export type { PgSearchHighlightOptions } from './types'; +export type { PgSearchOptions, PgSearchHighlightOptions } from './types';