Class: SearchClient
The AI Search client. Construct it with createSearchClient (which reads a resolved config) or directly for one-off use. All reads resolve the OBO workspace client from the active execution context.
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new SearchClient(
config?,workspaceClientFactory?,readBackend?):SearchClient
Parameters
Section titled “Parameters”config?
Section titled “config?”ResolvedSearchConfig = ...
workspaceClientFactory?
Section titled “workspaceClientFactory?”() => WorkspaceClient
readBackend?
Section titled “readBackend?”Returns
Section titled “Returns”SearchClient
Methods
Section titled “Methods”addDocuments()
Section titled “addDocuments()”addDocuments(
reference,documents,signal?):Promise<{count:number;index:string; }>
Add or update documents in a direct-access index.
Parameters
Section titled “Parameters”reference
Section titled “reference”string
documents
Section titled “documents”Record<string, unknown>[]
signal?
Section titled “signal?”AbortSignal
Returns
Section titled “Returns”Promise<{ count: number; index: string; }>
createIndex()
Section titled “createIndex()”createIndex(
name,options?):Promise<IndexInfo>
Create an AI Search index with as little ceremony as possible. Two shapes:
- Delta Sync (the default): pass
sourceTable; Databricks computes embeddings from the text column and keeps the index synced. The embedding model is resolved automatically when not named. - Direct Access: omit
sourceTableand passembeddingDimension; you write vectors yourself via addDocuments.
Everything else infers: the endpoint from the plugin config, the primary
key (id), the text column (text / content / body), and the vector
column (embedding). Returns the created index’s IndexInfo.
Parameters
Section titled “Parameters”string
options?
Section titled “options?”CreateIndexOptions = {}
Returns
Section titled “Returns”Promise<IndexInfo>
deleteDocuments()
Section titled “deleteDocuments()”deleteDocuments(
reference,ids,signal?):Promise<{count:number;index:string; }>
Delete documents from a direct-access index by primary key.
Parameters
Section titled “Parameters”reference
Section titled “reference”string
(string | number)[]
signal?
Section titled “signal?”AbortSignal
Returns
Section titled “Returns”Promise<{ count: number; index: string; }>
deleteIndex()
Section titled “deleteIndex()”deleteIndex(
reference,signal?):Promise<void>
Delete an index.
Parameters
Section titled “Parameters”reference
Section titled “reference”string
signal?
Section titled “signal?”AbortSignal
Returns
Section titled “Returns”Promise<void>
embed()
Section titled “embed()”embed(
texts,model?,signal?):Promise<number[][]>
Embed text via a Databricks embedding serving endpoint, returning one vector per input. Used to seed a direct-access index and to turn a search query into a query vector - Databricks only manages embeddings for Delta Sync indexes, so a direct-access index (no Delta table, no warehouse) needs the client to embed on write and on query. The endpoint is resolved the same way as for index creation when not named.
Parameters
Section titled “Parameters”string[]
model?
Section titled “model?”string
signal?
Section titled “signal?”AbortSignal
Returns
Section titled “Returns”Promise<number[][]>
ensureEndpoint()
Section titled “ensureEndpoint()”ensureEndpoint(
name?,options?):Promise<void>
Ensure a Vector Search endpoint exists, creating a STANDARD one when it
does not. Optionally wait for it to come online. Idempotent.
Parameters
Section titled “Parameters”string
options?
Section titled “options?”Returns
Section titled “Returns”Promise<void>
ensureIndex()
Section titled “ensureIndex()”ensureIndex(
name,options?):Promise<IndexInfo>
Create the index if it does not already exist, otherwise return the existing one. Idempotent - safe to call on every boot to guarantee an index is present.
Parameters
Section titled “Parameters”string
options?
Section titled “options?”CreateIndexOptions = {}
Returns
Section titled “Returns”Promise<IndexInfo>
getIndex()
Section titled “getIndex()”getIndex(
reference,signal?):Promise<IndexInfo>
Fetch an index’s live definition.
Parameters
Section titled “Parameters”reference
Section titled “reference”string
signal?
Section titled “signal?”AbortSignal
Returns
Section titled “Returns”Promise<IndexInfo>
index()
Section titled “index()”index(
reference):SearchIndex
A handle bound to one index (by full UC name or configured alias).
Parameters
Section titled “Parameters”reference
Section titled “reference”string
Returns
Section titled “Returns”listIndexes()
Section titled “listIndexes()”listIndexes(
endpoint?,signal?):Promise<string[]>
List the indexes hosted on a Vector Search endpoint (name + type only).
Parameters
Section titled “Parameters”endpoint?
Section titled “endpoint?”string
signal?
Section titled “signal?”AbortSignal
Returns
Section titled “Returns”Promise<string[]>
provision()
Section titled “provision()”provision(
name,options?):Promise<IndexInfo>
Ensure an index exists, is online, and (optionally) holds seed data - the “wire up a real index on boot” path. Idempotent and cheap to call every boot: it creates the endpoint and index only if missing, waits for them to come online, and seeds documents ONLY when the index is still empty.
For the demo/dummy-data case this needs no Delta table and no warehouse:
the default is a MANAGED direct-access index (Databricks embeds the text
column on write and query), so seeding is just an addDocuments of plain
rows and search-by-text works immediately.
Parameters
Section titled “Parameters”string
options?
Section titled “options?”ProvisionOptions = {}
Returns
Section titled “Returns”Promise<IndexInfo>
resolveEmbeddingModel()
Section titled “resolveEmbeddingModel()”resolveEmbeddingModel(
requested?,signal?):Promise<string|null>
Resolve an embedding endpoint id for creating a Delta Sync index. Reuses the model resolver: a configured / passed name is fuzzy-matched against the live catalogue, otherwise the highest-ranked embedding endpoint is chosen.
Parameters
Section titled “Parameters”requested?
Section titled “requested?”string
signal?
Section titled “signal?”AbortSignal
Returns
Section titled “Returns”Promise<string | null>
search()
Section titled “search()”search(
query,options?):Promise<{count:number;hits:object[];index?:string;query:string; }>
Search one index. index may be a full UC name, a configured alias, or
omitted to use the default index. Returns hits sorted most-relevant-first.
Parameters
Section titled “Parameters”string
options?
Section titled “options?”SearchOptions & object = {}
Returns
Section titled “Returns”Promise<{ count: number; hits: object[]; index?: string; query: string; }>
syncIndex()
Section titled “syncIndex()”syncIndex(
reference,signal?):Promise<void>
Trigger a sync of a Delta Sync index from its source table.
Parameters
Section titled “Parameters”reference
Section titled “reference”string
signal?
Section titled “signal?”AbortSignal
Returns
Section titled “Returns”Promise<void>
universalSearch()
Section titled “universalSearch()”universalSearch(
query,options?):Promise<{count:number;hits:object[];index?:string;query:string; }>
Fan a query across several indexes and merge the hits, sorted by score - the “universal search” a single box over many collections needs. Each index is searched concurrently; an index that errors is logged and skipped so one bad index does not sink the whole search.
Parameters
Section titled “Parameters”string
options?
Section titled “options?”Returns
Section titled “Returns”Promise<{ count: number; hits: object[]; index?: string; query: string; }>