TuGraph-family / tugraph-db

TuGraph: A High Performance Graph Database.
https://tugraph.org
Apache License 2.0
1.44k stars 192 forks source link

support vector index #612

Closed Jant1L closed 2 months ago

Jant1L commented 3 months ago

Support create vector index and query similarity

How to create a vertex which contains vector property: eg: _CALL db.createVertexLabel('person', 'id', 'id', 'int64', false, 'vector', 'floatvector', true); CREATE (n:person {id:2001, vector: [1.0,2.0,3.0]});

Create vector index: vector.AddVectorIndex(label_name, field_name, index_type, vec_dimension, distance_type ,index_spec); eg:for HNSW, it need 2 parameters for index_spec:Max_degree && ef_construction CALL vector.AddVectorIndex('person', 'vector', 'HNSW', 4, 'L2' ,24 , 100);

Delete vector index: vector.DeleteVectorIndex(label_name, field_name, index_type, vec_dimension, distance_type); eg: CALL vector.DeleteVectorIndex('person', 'vector', ' HNSW ', 4, 'L2');

Show vector index: CALL vector.ShowVectorIndex();

Query by using vector index: CALL vector.VectorIndexQuery(label_name, field_name, vector, vec_dimension, query_spec); eg:for HNSW, it need 1 parameter for index_spec:ef_search CALL vector.VectorIndexQuery('person', 'vector', [1,2,3,4], 4, 10);

What support now: VSAG HNSW

TODO: support more vector index algorithm and library

CLAassistant commented 3 months ago

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
3 out of 4 committers have signed the CLA.

:white_check_mark: Jant1L
:white_check_mark: PPPoint-t
:white_check_mark: lipanpan03
:x: tugraph


tugraph seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

CLAassistant commented 3 months ago

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 2 committers have signed the CLA.

:white_check_mark: Jant1L
:x: PPPoint-t
You have signed the CLA already but the status is still pending? Let us recheck it.

ljcui commented 2 months ago

test case 在哪里?

PPPoint-t commented 2 months ago

test case 在哪里?

submit test case

ljcui commented 2 months ago
MATCH (m:Movie {title: 'Godfather, The'})
CALL db.index.vector.queryNodes('moviePlots', 5, m.embedding)
YIELD node AS movie, score
where movie.title = 'xxxxxx'
RETURN movie, score

参考这种写法,向量查出来的点可以继续配合cypher的其他语法来做逻辑处理。 类似这种的查询需要可以跑通,不然用户层面无法使用。

ljcui commented 2 months ago

这一版,先暂时合并进去。