Interface LibrarySearch

A search.

interface LibrarySearch {
    text: string;
    scope: LibraryScope;
    mode?: "hybrid" | "lexical" | "dense";
    topK?: number;
    kinds?: string[];
    folderId?: string;
    folderIds?: string[];
    tags?: string[];
    sourceIds?: string[];
    anyOf?: Pick<LibrarySearch, "tags" | "kinds" | "folderId" | "folderIds" | "sourceIds">[];
    match?: "any" | "all";
    prefix?: boolean;
    signal?: AbortSignal;
}

Properties

text: string
mode?: "hybrid" | "lexical" | "dense"

lexical embeds nothing; hybrid fuses both legs where the store can; dense is the embedding alone.

Default

'hybrid'
topK?: number

The most passages answered.

Default

10
kinds?: string[]

Only these kinds of source; an empty list narrows nothing.

folderId?: string

Only the sources filed in this folder.

folderIds?: string[]

Only the sources filed in any of these folders; an empty list finds nothing, without a call to the embedder or the store. With folderId as well, both apply.

tags?: string[]

Every one of these tags; an empty list narrows nothing.

sourceIds?: string[]

Only these sources; an empty list finds nothing, without a call to the embedder or the store.

anyOf?: Pick<LibrarySearch, "tags" | "kinds" | "folderId" | "folderIds" | "sourceIds">[]

Several narrowings at once: a passage is found when any one of them holds. Each is searched with the one embedding of the text under the same scope, a passage found twice kept once, and the answer is ranked as one search's: each leg by the passage's own score across every branch (its similarity to the text, the lexical rank of the text's words in it), the two legs of a hybrid search fused once. A branch's fields replace the search's own of the same name. An empty list finds nothing, as does a list whose every branch finds nothing by its own narrowing, and neither calls the embedder or the store. The legs are the store's query and lexicalSearch, never its hybridSearch; on a store without lexicalSearch, a hybrid search is answered by the dense leg alone.

match?: "any" | "all"

For the lexical leg, alone or in a hybrid search: every word or any word (default), and whether a stored word may only begin with a query word.

prefix?: boolean
signal?: AbortSignal

Cancels the search: checked before and after the query is embedded and before and after each call to the store, and handed to the embedding function. Once it has aborted, the search starts no further call to the embedder or the store and rejects with the signal's reason, or with the embedding function's error when the signal cancelled its request; a store call that has started runs to its end, and its answer is dropped.