react-native-nitro-sqlite-vecFunctions
API Reference / react-native-nitro-sqlite-vec / knnSearch
Function: knnSearch()
knnSearch(
db,table,query,k,options?):KnnMatch[]
Search a vec0 table for the nearest vectors.
Executes synchronously and returns matches ordered by increasing distance.
Parameters
db
Open NitroSQLite connection with sqlite-vec enabled.
table
string
Trusted SQL table identifier, interpolated into the statement.
query
string | number[]
JSON vector string passed through unchanged, or a numeric array serialized as JSON.
k
number
Maximum number of matches requested.
options?
Optional trusted vector column identifier.
Returns
KnnMatch[]
Matching row IDs and distances, or an empty array when no rows are returned.