diff --git a/versioned_docs/version-1.x/surrealql/operators.mdx b/versioned_docs/version-1.x/surrealql/operators.mdx index 4e4c7a6c8..d9d74afe1 100644 --- a/versioned_docs/version-1.x/surrealql/operators.mdx +++ b/versioned_docs/version-1.x/surrealql/operators.mdx @@ -784,4 +784,15 @@ ORDER BY score DESC; ] ``` +## `#KNN` {#KNN} + +Performs a K-Nearest Neighbors (KNN) search to find a specified number of records closest to a given data point, optionally using a defined distance metric. Supports customizing the number of results and choice of distance calculation method. + +```surql +CREATE pts:3 SET point = [8,9,10,11]; +DEFINE INDEX mt_pts ON pts FIELDS point MTREE DIMENSION 4; +SELECT id, vector::distance::euclidean(point, [2,3,4,5]) AS dist FROM pts WHERE point <|2,EUCLIDEAN|> [2,3,4,5]; +SELECT id FROM pts WHERE point <|2|> [2,3,4,5] EXPLAIN; +``` +

\ No newline at end of file