import * as _backstage_backend_plugin_api from '@backstage/backend-plugin-api'; import { LoggerService, DatabaseService } from '@backstage/backend-plugin-api'; import { IndexableDocument, SearchQuery, IndexableResultSet } from '@backstage/plugin-search-common'; import { Knex } from 'knex'; import { BatchSearchEngineIndexer, SearchEngine } from '@backstage/plugin-search-backend-node'; import { Config } from '@backstage/config'; /** * @public * Search backend module for the Postgres engine. */ declare const _default: _backstage_backend_plugin_api.BackendFeature; /** @public */ type PgSearchEngineIndexerOptions = { batchSize: number; type: string; databaseStore: DatabaseStore; logger?: LoggerService; }; /** @public */ declare class PgSearchEngineIndexer extends BatchSearchEngineIndexer { private logger?; private store; private type; private tx; private numRecords; constructor(options: PgSearchEngineIndexerOptions); initialize(): Promise; index(documents: IndexableDocument[]): Promise; finalize(): Promise; } /** * Search query that the Postgres search engine understands. * @public */ type ConcretePgSearchQuery = { pgQuery: PgSearchQuery; pageSize: number; }; /** * Options available for the Postgres specific query translator. * @public */ type PgSearchQueryTranslatorOptions = { highlightOptions: PgSearchHighlightOptions; normalization?: number; }; /** * Postgres specific query translator. * @public */ type PgSearchQueryTranslator = (query: SearchQuery, options: PgSearchQueryTranslatorOptions) => ConcretePgSearchQuery; /** * Options to instantiate PgSearchEngine * @public */ type PgSearchOptions = { database: DatabaseService; logger?: LoggerService; }; /** * Options for highlighting search terms * @public */ type PgSearchHighlightOptions = { useHighlight?: boolean; maxWords?: number; minWords?: number; shortWord?: number; highlightAll?: boolean; maxFragments?: number; fragmentDelimiter?: string; preTag: string; postTag: string; }; /** @public */ declare class PgSearchEngine implements SearchEngine { private readonly logger?; private readonly highlightOptions; private readonly indexerBatchSize; private readonly normalization; private readonly databaseStore; /** * @deprecated This will be marked as private in a future release, please us fromConfig instead */ constructor(databaseStore: DatabaseStore, config: Config, logger?: LoggerService); private getNormalizationValue; private evaluateBitwiseOrExpression; /** * @deprecated This will be removed in a future release, please use fromConfig instead */ static from(options: { database: DatabaseService; config: Config; logger?: LoggerService; }): Promise; static fromConfig(config: Config, options: PgSearchOptions): Promise; static supported(database: DatabaseService): Promise; translator(query: SearchQuery, options: PgSearchQueryTranslatorOptions): ConcretePgSearchQuery; setTranslator(translator: PgSearchQueryTranslator): void; getIndexer(type: string): Promise; query(query: SearchQuery): Promise; } /** @public */ interface PgSearchQuery { fields?: Record; types?: string[]; pgTerm?: string; offset: number; limit: number; normalization?: number; options: PgSearchHighlightOptions; } /** @public */ interface DatabaseStore { transaction(fn: (tx: Knex.Transaction) => Promise): Promise; getTransaction(): Promise; prepareInsert(tx: Knex.Transaction): Promise; insertDocuments(tx: Knex.Transaction, type: string, documents: IndexableDocument[]): Promise; completeInsert(tx: Knex.Transaction, type: string, truncate?: boolean): Promise; query(tx: Knex.Transaction, pgQuery: PgSearchQuery): Promise; } /** @public */ interface RawDocumentRow { document: IndexableDocument; type: string; hash: unknown; } /** @public */ interface DocumentResultRow { /** * Total number of documents matching the query, regardless of pagination. */ total_count: string; document: IndexableDocument; type: string; highlight: IndexableDocument; } /** @public */ declare class DatabaseDocumentStore implements DatabaseStore { static create(database: DatabaseService): Promise; static supported(knex: Knex): Promise; private readonly db; constructor(db: Knex); transaction(fn: (tx: Knex.Transaction) => Promise): Promise; getTransaction(): Promise; prepareInsert(tx: Knex.Transaction): Promise; completeInsert(tx: Knex.Transaction, type: string, truncate?: boolean): Promise; insertDocuments(tx: Knex.Transaction, type: string, documents: IndexableDocument[]): Promise; query(tx: Knex.Transaction, searchQuery: PgSearchQuery): Promise; } export { DatabaseDocumentStore, PgSearchEngine, PgSearchEngineIndexer, _default as default }; export type { ConcretePgSearchQuery, DatabaseStore, DocumentResultRow, PgSearchEngineIndexerOptions, PgSearchHighlightOptions, PgSearchOptions, PgSearchQuery, PgSearchQueryTranslator, PgSearchQueryTranslatorOptions, RawDocumentRow };