Type a task you’re working on or a function name, then press Search. Compare the results under Keyword, Semantic, and Hybrid. Keyword results appear while a worker loads the embedding model for the first custom query. The worker encodes your text in your browser and reuses the model for later searches.
Use API name to find compressedSparseRowGraph. Try Customer quotas to find the rate-limit module by meaning. Sample a stream shows a query where both methods put the same module first.
Knotkit builds the keyword index once. NumPyTS multiplies the document matrix by the query vector to score every document. With unit-length embeddings, the dot product is cosine similarity. Reciprocal rank fusion combines the first ten hits from each method. A document gets more credit for appearing higher in either list.
Use Knotkit from source and install numpy-ts@1.8.0. Pass documents and query vectors produced by the same embedding model.
The demo bundles BGE-small embeddings for the module summaries and example queries. The first custom search downloads the 34 MB model and the WebAssembly runtime. The fixture generator at apps/docs/scripts/embed-hybrid-search.py records the model revision and reads the module summaries and API names from the capability catalog.
Build a read-only counted index from caller-tokenized documents. The selector runs once per input record.
The index retains terms, counts, and document positions. It can discard the source records after construction.
Expected O(n + t) build time for n documents and t token occurrences, plus the selector's work.
Build workspace and retained storage are O(n + v + p) for v vocabulary terms and p distinct postings.
@throws ― {TermIndexInvalidInputError} With INVALID_TERMS for a selector result other than an array of strings
or MAX_CAPACITY_EXCEEDED when corpus counts or packed storage exceed their bounds.
Errors thrown by the input iterable and selector propagate.
Split a string into substrings using the specified separator and return them as an array.
@param ― separator A string that identifies character or characters to use in separating the string. If omitted, a single-element array containing the entire string is returned.
@param ― limit A value used to limit the number of elements returned in the array.
split(
' ',
),
)
const
constterms: (text:string) =>string[]
terms= (
text: string
text:string):string[] =>
(
text: string
text.
String.toLowerCase(): string
Converts all the alphabetic characters in a string to lowercase.
Matches a string or an object that supports being matched against, and returns an array
containing the results of that search, or null if no matches are found.
@param ― matcher An object that supports being matched against.
Returns the elements of an array that meet the condition specified in a callback function.
@param ― predicate A function that accepts up to three arguments. The filter method calls the predicate function one time for each element in the array.
@param ― thisArg An object to which the this keyword can refer in the predicate function. If thisArg is omitted, undefined is used as the this value.
filter((
term: string
term) =>!
conststopWords:Set<string>
stopWords.
Set<string>.has(value: string): boolean
@returns ― a boolean indicating whether an element with the specified value exists in the Set or not.
Build a read-only counted index from caller-tokenized documents. The selector runs once per input record.
The index retains terms, counts, and document positions. It can discard the source records after construction.
Expected O(n + t) build time for n documents and t token occurrences, plus the selector's work.
Build workspace and retained storage are O(n + v + p) for v vocabulary terms and p distinct postings.
@throws ― {TermIndexInvalidInputError} With INVALID_TERMS for a selector result other than an array of strings
or MAX_CAPACITY_EXCEEDED when corpus counts or packed storage exceed their bounds.
Errors thrown by the input iterable and selector propagate.
Calls a defined callback function on each element of an array, and returns an array that contains the results.
@param ― callbackfn A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array.
@param ― thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.
Rank documents matching any supplied exact term. Ties in score favor lower IDs.
Repeated query terms contribute once. The returned array and hits are independent of the index.
@throws ― {TermIndexInvalidInputError} With INVALID_LIMIT for a limit outside the nonnegative safe integers
or INVALID_TERMS for an argument other than an array of strings. Eligibility accessor errors propagate.
search(
constterms: (text:string) =>string[]
terms(
query: string
query), {
TermSearchOptions.limit?: number |undefined
Maximum number of hits. Defaults to 10. Zero yields no hits.
Calls a defined callback function on each element of an array, and returns an array that contains the results.
@param ― callbackfn A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array.
@param ― thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.
A typed array of 64-bit float values. The contents are initialized to 0. If the requested
number of bytes could not be allocated an exception is raised.
Returns a copy of an array with its elements sorted.
@param ―
compareFn Function used to determine the order of the elements. It is expected to return
a negative value if the first argument is less than the second argument, zero if they're equal, and a positive
value otherwise. If omitted, the elements are sorted in ascending, UTF-16 code unit order.
[11, 2, 22, 1].toSorted((a, b) => a - b) // [1, 2, 11, 22]
Returns a copy of a section of an array.
For both start and end, a negative index can be used to indicate an offset from the end of the array.
For example, -2 refers to the second to last element of the array.
@param ― start The beginning index of the specified portion of the array.
If start is undefined, then the slice begins at index 0.
@param ― end The end index of the specified portion of the array. This is exclusive of the element at the index 'end'.
If end is undefined, then the slice extends to the end of the array.
slice(0,
constshortlistSize:10
shortlistSize)
const
constscores:Map<number, number>
scores=new
var Map:MapConstructor
new <number, number>(iterable?:Iterable<readonly [number, number]> |null|undefined) =>Map<number, number> (+3 overloads)
Adds a new element with a specified key and value to the Map. If an element with the same key already exists, the element will be updated.
set(
constid:number
id, (
constscores:Map<number, number>
scores.
Map<number, number>.get(key: number): number |undefined
Returns a specified element from the Map object. If the value that is associated to the provided key is an object, then you will get a reference to that object and any change made to that object will effectively modify it inside the Map.
@returns ― Returns the element associated with the specified key. If no element is associated with the specified key, undefined is returned.
Returns a copy of an array with its elements sorted.
@param ―
compareFn Function used to determine the order of the elements. It is expected to return
a negative value if the first argument is less than the second argument, zero if they're equal, and a positive
value otherwise. If omitted, the elements are sorted in ascending, UTF-16 code unit order.
[11, 2, 22, 1].toSorted((a, b) => a - b) // [1, 2, 11, 22]
Calls a defined callback function on each element of an array, and returns an array that contains the results.
@param ― callbackfn A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array.
@param ― thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.