限制和跳过密码匹配查询

Limit and skip cypher match query

我正在尝试使用基于得分的余弦相似度来创建关系

MATCH (u1:User)-[x:SCORE]->(p:Place)<-[y:SCORE]-(u2:User)
WITH SUM(x.score * y.score) AS xyDotProduct,
SQRT(REDUCE(xDot = 0.0, a IN COLLECT(x.score)) | xDot + a^2)) AS xLength,
SQRT(REDUCE(yDot = 0.0, b IN COLLECT(y.score) | yDot + b^2)) AS yLength,
u1, u2
MERGE (u1)-[s:SIMILARITY]-(u2)
SET s.similarity = xyDotProduct / (xLength * yLength)

在 docker 容器中在 Java 堆上中断..

如何将查询限制为 1000 条记录,然后为接下来的 1000 条记录重新运行?

您可以在第一个匹配后添加一个 WHERE NOT 子句和一个限制,例如:

MATCH (u1:User)-[x:SCORE]->(p:Place)<-[y:SCORE]-(u2:User)
WHERE NOT (u1)-[:SIMILARITY]-(u2)
WITH u1, x, p, y, u2
LIMIT 1000
WITH SUM(x.score * y.score) AS xyDotProduct,
SQRT(REDUCE(xDot = 0.0, a IN COLLECT(x.score)) | xDot + a^2)) AS xLength,
SQRT(REDUCE(yDot = 0.0, b IN COLLECT(y.score) | yDot + b^2)) AS yLength,
u1, u2
MERGE (u1)-[s:SIMILARITY]-(u2)
SET s.similarity = xyDotProduct / (xLength * yLength)