Skip to content

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.

new SearchClient(config?, workspaceClientFactory?, readBackend?): SearchClient

ResolvedSearchConfig = ...

() => WorkspaceClient

SearchReadBackend

SearchClient

addDocuments(reference, documents, signal?): Promise<{ count: number; index: string; }>

Add or update documents in a direct-access index.

string

Record<string, unknown>[]

AbortSignal

Promise<{ count: number; index: string; }>


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 sourceTable and pass embeddingDimension; 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.

string

CreateIndexOptions = {}

Promise<IndexInfo>


deleteDocuments(reference, ids, signal?): Promise<{ count: number; index: string; }>

Delete documents from a direct-access index by primary key.

string

(string | number)[]

AbortSignal

Promise<{ count: number; index: string; }>


deleteIndex(reference, signal?): Promise<void>

Delete an index.

string

AbortSignal

Promise<void>


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.

string[]

string

AbortSignal

Promise<number[][]>


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.

string

EnsureEndpointOptions = {}

Promise<void>


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.

string

CreateIndexOptions = {}

Promise<IndexInfo>


getIndex(reference, signal?): Promise<IndexInfo>

Fetch an index’s live definition.

string

AbortSignal

Promise<IndexInfo>


index(reference): SearchIndex

A handle bound to one index (by full UC name or configured alias).

string

SearchIndex


listIndexes(endpoint?, signal?): Promise<string[]>

List the indexes hosted on a Vector Search endpoint (name + type only).

string

AbortSignal

Promise<string[]>


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.

string

ProvisionOptions = {}

Promise<IndexInfo>


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.

string

AbortSignal

Promise<string | null>


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.

string

SearchOptions & object = {}

Promise<{ count: number; hits: object[]; index?: string; query: string; }>


syncIndex(reference, signal?): Promise<void>

Trigger a sync of a Delta Sync index from its source table.

string

AbortSignal

Promise<void>


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.

string

UniversalSearchOptions = {}

Promise<{ count: number; hits: object[]; index?: string; query: string; }>