basalt / search-postgres/src / PostgresSearchDriver
Class: PostgresSearchDriver
Defined in: search-postgres/src/index.ts:85
PostgreSQL full-text search driver for @basaltkit/search, using tsvector/tsquery and ts_rank. All documents live in one table keyed by (index, tenant, id); every query is constrained to the caller's tenant, so results never leak. Bring a pg client — it's injected, so the SQL is unit-tested without a database.
Implements
Constructors
Constructor
> new PostgresSearchDriver(options): PostgresSearchDriver
Defined in: search-postgres/src/index.ts:92
Parameters
options
Returns
PostgresSearchDriver
Methods
bulk()
> bulk(indexName, documents): Promise<void>
Defined in: search-postgres/src/index.ts:136
Parameters
indexName
string
documents
Returns
Promise<void>
Implementation of
clear()
> clear(indexName): Promise<void>
Defined in: search-postgres/src/index.ts:144
Drops every document in the index — every tenant's. Used by a whole-index reindex({ all: true }) and by tests.
Parameters
indexName
string
Returns
Promise<void>
Implementation of
clearTenant()
> clearTenant(indexName, tenantId): Promise<void>
Defined in: search-postgres/src/index.ts:148
Drops every document of ONE tenant in the index and leaves every other tenant's documents untouched. Used by a tenant-scoped reindex().
Optional so a custom driver written against the older contract still compiles — but Search refuses a scoped rebuild on a driver without it (SearchDriverCapabilityError) instead of falling back to clear, which would wipe every other tenant. Implementations must delete by the stored tenantId (delete-by-query / WHERE tenant_id = …), never by listing ids through search, which is paged and can miss rows.
Parameters
indexName
string
tenantId
string
Returns
Promise<void>
Implementation of
index()
> index(indexName, document): Promise<void>
Defined in: search-postgres/src/index.ts:118
Parameters
indexName
string
document
Returns
Promise<void>
Implementation of
register()
> register(index): Promise<void>
Defined in: search-postgres/src/index.ts:105
Optional: called once per index at boot with its config.
Parameters
index
Returns
Promise<void>
Implementation of
remove()
> remove(indexName, tenantId, id): Promise<void>
Defined in: search-postgres/src/index.ts:140
Parameters
indexName
string
tenantId
string
id
string
Returns
Promise<void>
Implementation of
search()
> search(indexName, query): Promise<SearchResult>
Defined in: search-postgres/src/index.ts:152
Parameters
indexName
string
query
Returns
Promise<SearchResult>