VIEW (Vector index)
Warning
Supported only for row-oriented tables. Support for column-oriented tables is currently under development.
To select data from a row-oriented table using a vector index, use the following statements:
SELECT ...
FROM TableName VIEW IndexName
WHERE ...
ORDER BY Knn::SomeDistance(...)
LIMIT ...
SELECT ...
FROM TableName VIEW IndexName
WHERE ...
ORDER BY Knn::SomeSimilarity(...) DESC
LIMIT ...
Note
The vector index will not be automatically selected by the optimizer, so it must be specified explicitly using the expression `VIEW IndexName'.
Examples
-
Select all the fields from the
series
row-oriented table using theviews_index
vector index created forembedding
and inner product similarity:SELECT series_id, title, info, release_date, views, uploaded_user_id, Knn::InnerProductSimilarity(embedding, $target) as similarity FROM series VIEW views_index ORDER BY similarity DESC LIMIT 10
-
Select all the fields from the
series
row-oriented table using theviews_index2
prefixed vector index created forembedding
and inner product similarity with prefix columnrelease_date
:SELECT series_id, title, info, release_date, views, uploaded_user_id, Knn::InnerProductSimilarity(embedding, $target) as similarity FROM series VIEW views_index2 WHERE release_date = "2025-03-31" ORDER BY Knn::InnerProductSimilarity(embedding, $TargetEmbedding) DESC LIMIT 10
Was the article helpful?
Previous
Next