2016-06-16 1 views
0

Je suis en train de créer une relation en utilisant la similarité cosinus basée sur le scoreLimit et sauter correspondance des requêtes de Cypher

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) 

dans un casse conteneur docker sur Java Heap ..

Comment puis-je limiter la requête pour 1000 enregistrements, puis relancer pour les 1000 prochains enregistrements?

Répondre

3

Vous pouvez ajouter une clause WHERE NOT et une limite après le premier match, par exemple:

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)