我想使用cypher测试GraphDB之间的简单图形分析性能。
我引用了this site,并在Neo4j,Agensgraph,SAP HANA和Redis中重现了示例。
,但是密码查询(请参见下文)在Agensgraph和SAP HANA中未运行。
MATCH (p1:Person {name:'Michael Sherman'})-[r1:RATED]->(m:Movie)<-[r2:RATED]-(p2:Person {name:'Michael Hunger'}) RETURN m.name AS Movie, r1.rating AS `M. Sherman's Rating`, r2.rating AS `M. Hunger's Rating`
我认为第二个箭头模式在Agensgraph和SAP HANA中不起作用。
如何编辑此查询以在Agensgraph和SAP HANA中运行?
答案 0 :(得分:0)
由于查询语言语法的差异,我已经遇到了类似的问题。
这是我的查询,用于找出AgesnGraph中的相似性。您只需进行少量修改就可以计算余弦相似度。
MATCH (u1:users {userid:'Toby'})-[r1:hasrated]->(m:movies)<-[r2:hasrated]-(u2:users)
WITH distinct u1.userid as u1name, u2.userid as u2name,
SUM(r1.rating::float*r2.rating::float) as xyDotProduct,
SQRT(SUM(r1.rating::float^2)) as xLength,
SQRT(SUM(r2.rating::float^2)) as yLength
RETURN u1name, u2name, xyDotProduct::float/(xLength::float*yLength::float) as similarity;