Method QueryAsync
QueryAsync(SqliteConnection, string, ReadOnlyMemory<float>, int, string?, IEnumerable<SqliteParameter>?, string, CancellationToken)
Runs a KNN query against a vec0 table and returns the matched row ids and distances.
public static Task<IReadOnlyList<KnnHit>> QueryAsync(SqliteConnection connection, string table, ReadOnlyMemory<float> query, int k, string? where = null, IEnumerable<SqliteParameter>? parameters = null, string vectorColumn = "embedding", CancellationToken cancellationToken = default)
Parameters
connectionSqliteConnectionThe open connection to query on.
tablestringThe
vec0table to query.queryReadOnlyMemory<float>The query vector.
kintThe number of nearest neighbours to return.
wherestringAn additional
AND-joined predicate (metadata or partition-key filters), or null for none.parametersIEnumerable<SqliteParameter>Parameters bound by
where, or null for none.vectorColumnstringThe vector column's name.
cancellationTokenCancellationTokenCancels the command.
Returns
- Task<IReadOnlyList<KnnHit>>
The matched rows, ordered nearest first.
Exceptions
- ArgumentNullException
connectionis null.- ArgumentOutOfRangeException
kis less than 1.