Client API
This reference lists the implemented @ktjn/searchable-client surface and the exact option names prepared for the planned 1.0.0 package. The package is not yet published to npm.
SearchClient
const client = new SearchClient(options);
const result = await client.search(query, searchOptions);
const final = await client.searchStream(query, streamOptions);
const facet = await client.facetValues(field, facetOptions);
const unsubscribe = client.on("result", ({ result }) => {});
client.dispose();
SearchClientOptions contains indexUrl, worker, workerUrl, allowCrossOriginShards, strict, embedQuery, and validateVectorProvider. indexUrl is required. Worker mode requires a workerUrl; otherwise calls execute directly.
Search options and results
SearchOptions contains:
language,limit, andboosts.fields/boosts.termsfiltersandfacetssynonyms/synonymWeightfuzzy/fuzzyWeighthighlightandsignalmode: "lexical" | "vector" | "hybrid"andvectorWeight
SearchResult contains hits, totalHits, and language, plus requested facets and optional didYouMean. Every Hit has id, score, url, and stored fields; it may include pinned and highlights.
Streaming/incremental results
SearchStreamOptions adds onPartial. A partial literal/prefix result is emitted only when synonym or fuzzy expansion requires a later final pass. AbortSignal cancels waiting for a caller without invalidating a shared cached fetch.
Facet-only queries
facetValues(field, options) accepts filters and signal through FacetValuesOptions and returns a FacetResult.
Events and lifecycle
on("query", listener) and on("result", listener) return unsubscribe functions. Events are local observation hooks; the library sends no analytics. dispose() is idempotent, terminates the worker, rejects pending work, and prevents future use.
Other exports
The package exports highlighting types, manifest validation (validateManifest, InvalidManifestError), offline caching (registerOfflineCaching), RTL detection, vector helpers and errors, and the optional Transformers query adapter. The complete type declarations shipped with the package are the normative API. Designs for warm-up, suggestions, federation, and broader diagnostics are archived and linked from the roadmap.