Class: LakebaseSearchBackend
A Postgres full-text backend. One instance is shared across indexes; each index maps to a table whose name is derived from the index reference.
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new LakebaseSearchBackend(
pgConfigFactory,schema?,poolFactory?):LakebaseSearchBackend
Parameters
Section titled “Parameters”pgConfigFactory
Section titled “pgConfigFactory”() => PoolConfig | Promise<PoolConfig>
schema?
Section titled “schema?”string = "public"
poolFactory?
Section titled “poolFactory?”(config) => Pool
How a pool is built from the resolved config. Overridable for tests.
Returns
Section titled “Returns”LakebaseSearchBackend
Methods
Section titled “Methods”addDocuments()
Section titled “addDocuments()”addDocuments(
index,documents,textColumn?,signal?):Promise<{count:number;index:string; }>
Add or update documents by primary key.
Parameters
Section titled “Parameters”string
documents
Section titled “documents”Record<string, unknown>[]
textColumn?
Section titled “textColumn?”string = "text"
signal?
Section titled “signal?”AbortSignal
Returns
Section titled “Returns”Promise<{ count: number; index: string; }>
close()
Section titled “close()”close():
Promise<void>
Close the pool so a restarted app rebuilds it.
Returns
Section titled “Returns”Promise<void>
deleteDocuments()
Section titled “deleteDocuments()”deleteDocuments(
index,ids,signal?):Promise<{count:number;index:string; }>
Delete documents by primary key.
Parameters
Section titled “Parameters”string
(string | number)[]
signal?
Section titled “signal?”AbortSignal
Returns
Section titled “Returns”Promise<{ count: number; index: string; }>
provision()
Section titled “provision()”provision(
index,options?):Promise<number>
Ensure the table + full-text index exist and seed documents when empty. Idempotent, so it is safe to call on every boot.
Parameters
Section titled “Parameters”string
options?
Section titled “options?”Returns
Section titled “Returns”Promise<number>
search()
Section titled “search()”search(
index,query,options?):Promise<{count:number;hits:object[];index?:string;query:string; }>
Search a Lakebase-backed index. Returns hits sorted most-relevant-first, shaped identically to the Vector Search backend.
Parameters
Section titled “Parameters”string
string
options?
Section titled “options?”Returns
Section titled “Returns”Promise<{ count: number; hits: object[]; index?: string; query: string; }>