Skip to content

Conversation

WanYixian
Copy link
Collaborator

@WanYixian WanYixian commented Sep 17, 2025

Description

See preview of vector index, Vector type and functions, create vector syntax

Related Code PR

risingwavelabs/risingwave#22432
risingwavelabs/risingwave#22022
risingwavelabs/risingwave#22808

Related doc issue

Fix #601

Checklist

  • I have run the documentation build locally to verify the updates are applied correctly.
  • For new pages, I have updated mint.json to include the page in the table of contents.
  • All links and references have been checked and are not broken.

@wenym1
Copy link
Contributor

wenym1 commented Sep 18, 2025

Actually, this feature deserves a separate page, instead of as a sub-feature of create index. We can refer to the README of pgvector. cc @hzxa21 @xiangjinwu

Following are mentionable items in the page.

  • new data type of Vector(n), where n is the dimension of the vector (may also update the page of data type, if there is any, and link to there)
  • new vector distance operators
"<->" => ExprType::L2Distance,
"<=>" => ExprType::CosineDistance,
"<+>" => ExprType::L1Distance,
"<#>" => {
    // inner product distance
}
  • example to do nearest distance vector search (<-> as distance operator, order by <distance> limit 5 as top n nearest vector)
SELECT * FROM items order by embedding <-> '[3,1,2]' limit 5;
  • create vector index, as mentioned in the PR description.
  • other vector functions. @xiangjinwu Can you help providing a list of newly supported vector functions? (may also update the page that shows all supported functions, and link to there)

@xiangjinwu
Copy link
Contributor

vector(n) operators and functions:

  • cast
    • vector(n) to varchar: assign
    • varchar to vector(n): explicit
    • vector(n) to real[]: implicit
    • int[]/numeric[]/real[]/double precision[] to vector(n): assign
  • distance
    • vector(n) <-> vector(n) → double precision / l2_distance(vector(n), vector(n)) → double precision
    • vector(n) <=> vector(n) → double precision / cosine_distance(vector(n), vector(n)) → double precision
    • vector(n) <+> vector(n) → double precision / l1_distance(vector(n), vector(n)) → double precision
    • vector(n) <#> vector(n) → double precision (note this is negative inner product)
    • inner_product(vector(n), vector(n)) → double precision
  • others
    • vector(n) + vector(n) → vector(n): element-wise addition
    • vector(n) - vector(n) → vector(n): element-wise subtraction
    • vector(n) * vector(n) → vector(n): element-wise multiplication
    • vector(m) || vector(n) → vector(m+n): concatenate
    • vector_norm(vector(n)) → double precision: Euclidean norm
    • l2_normalize(vector(n)) → vector(n): Normalize with Euclidean norm

@WanYixian
Copy link
Collaborator Author

Actually, this feature deserves a separate page, instead of as a sub-feature of create index. We can refer to the README of pgvector. cc @hzxa21 @xiangjinwu

Following are mentionable items in the page.

  • new data type of Vector(n), where n is the dimension of the vector (may also update the page of data type, if there is any, and link to there)
  • new vector distance operators
"<->" => ExprType::L2Distance,
"<=>" => ExprType::CosineDistance,
"<+>" => ExprType::L1Distance,
"<#>" => {
    // inner product distance
}
  • example to do nearest distance vector search (<-> as distance operator, order by <distance> limit 5 as top n nearest vector)
SELECT * FROM items order by embedding <-> '[3,1,2]' limit 5;
  • create vector index, as mentioned in the PR description.
  • other vector functions. @xiangjinwu Can you help providing a list of newly supported vector functions? (may also update the page that shows all supported functions, and link to there)

@wenym1 @xiangjinwu Updated the doc accordingly! Please take another look

Copy link
Contributor

@wenym1 wenym1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rest LGTM

Co-authored-by: William Wen <44139337+wenym1@users.noreply.github.com>
Signed-off-by: IrisWan <150207222+WanYixian@users.noreply.github.com>
Co-authored-by: William Wen <44139337+wenym1@users.noreply.github.com>
Signed-off-by: IrisWan <150207222+WanYixian@users.noreply.github.com>
Copy link
Contributor

@wenym1 wenym1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rest LGTM. Thanks for the doc!

Co-authored-by: William Wen <44139337+wenym1@users.noreply.github.com>
Signed-off-by: IrisWan <150207222+WanYixian@users.noreply.github.com>
@WanYixian WanYixian merged commit 27548ab into main Sep 29, 2025
6 checks passed
@WanYixian WanYixian deleted the wyx/fix-601 branch September 29, 2025 11:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Document: feat(frontend): support create vector index on frontend
3 participants